How do I script for quitting application and hitting "quit" button?

I’m making an Automator application to quit “Wondershare AllMyMusic” after a 3-hr pause while it records. I have a 3-hr “pause” action but I can’t use the “quit application” action because I get a “Do you want to quit?” pop up window with a “Don’t Quit” white button and a “Quit” blue button that can be selected by hitting return. I know almost nothing about writing script but here is what I’ve attempted, so far, trying to use the return key to select the “Quit” button:


tell application "Wondershare AllMyMusic"
     activate
     delay 1
     quit
     delay 1
     tell application "System Events"
          tell process "Wondershare AllMyMusic"
               keystroke "return"
          end tell
     end tell
end tell

It seems like this would be a common thing to run across for someone attempting to automate quitting an application but I’ve been unable to find information on this subject.

I found the answer to my question. Here is the code that worked (it uses command-Q to quit then keystroke return):


tell application "System Events"
    set frontmost of process "Wondershare AllMyMusic" to true
    keystroke "q" using command down
    keystroke return
end tell