I have my preferences set so that CTRL-D closes my current window, but I'd like the Terminal application to quit if I close my last/only terminal window. iTerm2 can do this. Can Terminal do it?

1 Answer 1


open applescript editor and paste in

on is_running(appName)
    tell application "System Events" to (name of processes) contains appName
end is_running

set app to "Terminal"

    if is_running(app) then
        tell application app
            set WindowNum to get window count
            if WindowNum = 0 then
            end if
        end tell
        delay 5
    end if
end repeat

Then save the script and run it by double-clicking it.

  • You can get this to work for most programs. Dec 17, 2015 at 17:46
  • How is this easier than quitting Terminal.app manually with the mouse or with Command-Q ? I think that is an implicit requirement in the OP.
    – q.undertow
    Aug 14, 2022 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .