Quit Application and Suppress Error Dialogs

I am trying to quit an application via Applescript. Even when I close the application by click the app’s red close button manually I get an error dialog. The app wants me to close it using keystrokes…

Is there a way to send keystrokes to an app with Applescript?

I am trying to close GLTron…here is what I’ve come up with, though it does not work:

–setup the down-arrow key
set myDown to ASCII character 31

if process "GLTron" exists then		
		tell application "GLTron"
			tell application "System Events"
				keystroke esc
				keystroke esc
				keystroke myDown
				keystroke myDown
				keystroke myDown
				keystroke space
				keystroke space
			end tell
		end tell
	end try
end if

Can anyone help with this?

Thank you!!

If it “listens”, then

ignoring application responses
– tell it to quit or do your clicks
end ignoring

Failing that,

do shell script “killall nameOfProcess” – equivalent to Force Quit

both ways give me the application quit unexpectedly dialog…any way around that?

GLTron has a web page and a forum - maybe they could help. Games are notorious for not behaving - they’re supposed to tell the system it’s ok to quit (allows for tidyup) and this one doesn’t. I can’t help you with the “quit unexpectedly” dialog - I can’t easily force one to play with. You might try using System Events to tell the frontmost window to keystroke return.

Thanks for the help Adam!!