Last Updated: September 09, 2019
·
995
· mattroyer

Quitting OS X Terminal Windows

When working with the terminal application on OS X, I find myself wanting the functionality I have on Linux and Windows terminals/consoles. When I type exit into the terminal, I want it to terminate all the way.

The OS X Terminal app doesn't do this automatically. It closes the window, yes, but it doesn't close the application for you. I looked at several solutions online, but didn't want to install anything new and didn't want to jump through 50 hoops.

So my solution is to add an alias to my ~/.bash_profile file. When you add this alias, you get in the habit of typing quit when you want to be completely done with the Terminal application. Add the following to your ~/.bash_profile (or whatever shell you use):

quit='osascript -e "tell application \"Terminal\" to quit"'

Once added and you get in the habit of typing quit when you want to close all Terminal windows, it makes life much easier. I can still type exit on individual windows, it doesn't monkey with any settings, and it's a simple one-liner. Enjoy!

10 Responses
Add your response

What’s wrong with cmd-w for quitting the tab or cmd-q for killing the app?

over 1 year ago ·

Nothing wrong at all and I do that from time to time. Searching around, other people have had this issue as well and have come up with complex solutions. It's only a personal preference. I don't like using my cmd key often.

over 1 year ago ·

Fair enough. Nice shell customisation..

over 1 year ago ·

But cmd-w/q are only two keys to press. 'Quit [enter]' are 5 keys... So what is faster? ;-)

over 1 year ago ·

Check preferences on the "shell" tab:

http://cl.ly/image/3g1F3H3e101x/o

( :

over 1 year ago ·

@sebastianzillessen cmd-w/q are definitely faster. I try to limit my use of those keys. I'm from a Vim background and anything that had to be done with a cmd/ctrl key, I've mapped to a comma + key-combo to make it quicker and put less strain on my wrists. Again, it's only my preference and I know a lot of people that would rather use cmd/ctrl keys.

@loisaidasam I had that set, but it didn't actually quit the terminal application, only closed the window. That was my main goal. To fully quit the application. Here are two discussions on this topic. There are many around:
http://stackoverflow.com/questions/5560167/how-should-i-properly-exit-terminal-using-a-terminal-command-on-mac-os-x

http://superuser.com/questions/158375/how-do-i-close-the-terminal-in-osx-from-the-command-line

Thanks for your comments everyone. I understand there are many ways to do this. And some of them are definitely better than this. Just wanted to show an option for people with preferences like me.

over 1 year ago ·

@sebastianzillessen you can always have an alias for Quit [enter], Something like 'q' :P
BTW, +1 to cmd+q

over 1 year ago ·

I use cmd+w on iterm2, or ctrl+d which also works to quit sshs, so if you are in a ssh session ctrl+d will close the session, another ctrl+d will close the window, tab, or panel.

over 1 year ago ·

@loisaidasam 's solution if fairly the cleanest, and it's right there in the application's settings.

over 1 year ago ·

@bhran that is the best way to have the window close, definitely. But it doesn't quit the terminal application. It only closes the open windows. I was looking for a way to quit the application itself without having to use cmd+q.

over 1 year ago ·