OSX - How to auto Close Terminal window after the "exit" command executed.

Solution 1:

in Terminal.app

Preferences > Profiles > (Select a Profile) > Shell.

on 'When the shell exits' chosen 'Close the window'

Solution 2:

How about the good old Command-Q?

Solution 3:

In the Terminal app, Preference >> Profiles tab.

Select the Shell tab on the right. enter image description here

You can choose Never Ask before closing to suppress the warning.

Solution 4:

Actually, you should set a config on your Terminal, when your Terminal is up press +, then you will see below screen:

enter image description here

Then press shell tab and you will see below screen:

enter image description here

Now select Close if the shell exited cleanly for When the shell exits.

By the above config each time with exit command the Terminal will close but won't quit.

Solution 5:

You could use AppleScript through the osascript command:

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