Проблема с подходом tell application "whatever" to quit
заключается в том, что вы можете ориентироваться только на приложения, которые установлены на вашем компьютере, после компиляции скрипта. Вот AppleScript, который определяет имена всех запущенных процессов приложения, а затем завершает каждый из них, отправляя ему команду quit
.
property pExcludeApps : {"Finder", name of current application}
tell application "System Events"
set theAppsToQuit to name of every process where background only = false
end tell
repeat with theApp in theAppsToQuit
if pExcludeApps does not contain contents of theApp then
tell application (contents of theApp)
quit saving yes
end tell
end if
end repeat