I am trying to make an Applescript to run with VoiceOver to popup a dialog asking to quit the current application. I was able to get one to work but it only works some of the time.I believe this is because of memory issues in some applications, that is why there is a delay. I tried telling the "frontmost" application to quit and it didn't work either.
display dialog "Quit current application?" buttons {"cancel", "ok"} default button "ok"
if result = {button returned:"ok"} then
delay 1.7
tell application "System Events" to key code 12 using command down
else if result = {button returned:"cancel"} then
end if