(* Save this as an Application, Stay-Open This script puts off quitting until the run procedure has completed. So it seems that to get a script to quit, control has to be released from any event handlers. *) on run try display dialog "We'll quit now, OK?" buttons "Cancel" on error tell me to quit end try tell me to saySomething() tell me to activate end run on saySomething() say "Something" end saySomething on quit say "By" -- this is performed when the quit is called, -- but for this to be carried out, any remaining events must be handled continue quit end quit on idle beep return 1 end idle on activate beep beep delay 2 beep delay 1 beep end activate