Quit All Open Apps at Once with osascript

Send a graceful quit signal to every foreground macOS application.

macOSosascriptsystemautomationMedium risk
Run the osascript loop over System Events foreground processes and tell each application to quit.

01Command

Command
$ osascript -e 'tell application "System Events" to set quitApps to (name of every process whose background only is false)' -e 'repeat with appName in quitApps' -e 'tell application appName to quit' -e 'end repeat'

02What it does

Unlike force-killing processes, `quit` lets each app show its save dialog and shut down cleanly, which prevents data loss and avoids the “reopen windows after crash” state. It is a common step before macOS updates, Time Machine restores, or rebooting a heavily used Mac.

03Risk

RiskMedium risk
!Warning: Unsaved documents will still prompt — sit at the Mac until the dialogs are handled, or you may block a scheduled shutdown. Skip this for apps you expect to relaunch automatically.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: System & Settings

06Related solutions