MacOS – How to close the Terminal in OSX from the command line

command lineexitmacosterminal

Why doesn't "exit" close a Terminal.app window on Mac OS X?

$ exit
logout

[Process completed]

Is there a way to close the window without using the mouse?

Best Answer

A window displayed by Terminal.app is just the frontend for the process you choose to run inside of it - in your case, a Unix shell. When you exit the shell, the Terminal.app does not close the window by default, so you have the possibility to inspect the output from whatever command you ran, after it finishes.

You can change your preferences here

Terminal Preferences -> Settings -> Shell:

to either

  1. always close the window, whatever the exit status of the shell was
  2. close the window if the shell exited cleanly
  3. keep the window open (the default)

Besides that, you can (almost) always close windows in OSX with Cmd-W, so you don't need mouse even if it doesn't close automatically.

One more hint: I like hitting Ctrl-D instead of typing exit. Two keys vs. five.

Related Question