A regular AppleScript does not have the ability to get system notifications, so you would have to do something like have the script continually check (poll) for applications that are running. A Cocoa-AppleScript does have the ability to do Cocoa-y stuff such as register for system notifications, so you can create a new applet (AppleScript Editor > File > New from Template > Cocoa-AppleScript Applet), paste in the following, and save it as an application (uncheck the option to show the startup screen):
propertytheApps : {"Final Draft"} -- a list of applications to watch for
onrun-- example
# add observers for workspace notifications
tellcurrent application's NSWorkspace's sharedWorkspace's notificationCenter
addObserver_selector_name_object_(me, "appQuit:", current application's NSWorkspaceDidTerminateApplicationNotification, missing value)
endtell
-- tell application "Final Draft" to activate
endrun
onappQuit_(aNotification) -- an application quit
# aNotification's userInfo record contains an NSRunningApplication instance that we can get properties from
settheApplicationto (aNotification's userInfo's NSWorkspaceApplicationKey's localizedName()) astext
iftheApplicationisintheAppsthen
tellcurrent application-- me
beep 3
activate-- make sure dialog comes to front
display dialog"BACK UP!!!!"with title"Final Draft quit notice"buttons {"OK"} default button1
quit
endtell
endif
endappQuit_
When the application is run it will sit there and receive notifications when other applications quit, and checks to see if it was the application you want.