How to close the Terminal automatically on macOS

If you are a regular user of the shell script on macOS you will notice that after completing the process it does not automatically close the Terminal, but the user must turn it off manually.

If you are a regular user of the shell script on macOS you will notice that after completing the process it does not automatically close the Terminal, but the user must turn it off manually. Therefore this article will show you how to close the Terminal automatically after completing the process.

This method only works when you launch the shell script outside bash such as clicking on it on the Finder or setting a custom hotkey to open the program. If not, you will be taken back to the Command Prompt. You can use the killall Terminal command to close the Terminal application from the script but it will close all open Terminal windows.

  1. How to customize Terminal on Mac
  2. 5 best alternatives for Terminal application on macOS
  3. Use commands and some tips for Mac OS X

Change behavior from Profile settings

Open the Terminal application from Dock or the Applications folder, then open the installation by pressing Command + Comma .

In the Settings window, go to the Profiles tab. Here, the default profile is always selected. In the settings on the right, click on the Shell tab and then click on the drop down menu When the shell exits .

Picture 1 of How to close the Terminal automatically on macOS

By default, the option Don't close the window is selected, but you can change it to Close if the shell exited cleanly .

Picture 2 of How to close the Terminal automatically on macOS

You can close this Terminal window all the time, but will receive an error message if the exit process is in non-zero exit status. Note, you need to exit the script with the exit command so that this behavior works at all times.

Picture 3 of How to close the Terminal automatically on macOS

If launched from the Finder, the exit command will automatically add to the script.

Use iTerm

  1. https://www.iterm2.com/

Picture 4 of How to close the Terminal automatically on macOS

iTerm2 is a popular Terminal replacement application for macOS, which automatically closes the window when the shell script exits. If you have used iTerm as the default Terminal, you can see that the shell script starting from the Finder remains open with the original Terminal application. So you still have this problem unless you have set it to open with iTerm.

You can change the application to open the script by right-clicking the script in the Finder and then selecting Get Info .

You will see a drop down menu to change the script open application, select iTerm and click Change All to apply changes to the scripts.

Picture 5 of How to close the Terminal automatically on macOS

By default, if you open the iTerm window, it will launch in a separate tab, not a separate window, and the tab will close automatically when the process is complete.

I wish you all success!

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile