How to automatically close Terminal.app on exit in OS X Lion

osx lionterminal

I've recently acquired a new Mac with OS X Lion, and I'm tuning it for my needs.

I was trying to configure autoclose on Terminal using its preferences (as I've done with Tiger and Snow Leopard) but it's not working. I've set "Close if the shell exited cleanly" but when I type exit, the window gets closed, but the Terminal.app is still open. Its menu is visible, and with alt+tab I can see it running.

Any suggestions?

Best Answer

This option has never closed the Terminal application.

Note that the other options are titled Close the window and Don't close the window (emphasis mine), making it clear that this setting refers to only closing the window, not the entire application.


You could define the following for your shell, e.g. in ~/.bash_profile for bash:

function exit {
    osascript -e 'tell application "Terminal" to quit' 
}

Then add osascript to the list of applications that don't require confirmation before quitting (in Preferences > Settings > Shell). Type exit to exit Terminal, unless there are other tabs with blocking programs running.

You can give it a different name to separate from a regular exit, of course. I like quit for this.

Related Question