tell application "Finder" if (processes whose frontmost is true) is {} then say "You cannot quit the Finder." return end if -- get the frontmost, scriptable application set appFront to processes whose frontmost is true and scriptable is true -- if this is an empty list, then frontmost app is not scriptable if (appFront is {}) then set appFront to processes whose frontmost is true say (appFront as string) & " is not scriptable." else -- it's scriptable, so tell it to quit -- say "Quitting " & (appFront as string) & "." tell appFront to quit end if end tell