in Terminal.app
Preferences > Profiles > (Select a Profile) > Shell.
on 'When the shell exits' chosen 'Close the window'
How about the good old Command-Q?
In the Terminal app, Preference >> Profiles tab.
Select the Shell tab on the right.
You can choose Never Ask before closing to suppress the warning.
Actually, you should set a config on your Terminal, when your Terminal is up press ⌘+, then you will see below screen:
Then press shell tab and you will see below screen:
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.
You could use AppleScript through the osascript
command:
osascript -e 'tell application "Terminal" to quit'
In a terminal window, you can type:
kill -9 $(ps -p $PPID -o ppid=)
This will kill the Terminal application process, which is the parent of the parent of the current process, as seen by the kill command.
To close a Terminal window from within a running script, you need to go up one more level in the process hierarchy like this:
kill -9 $(ps -p $(ps -p $PPID -o ppid=) -o ppid=)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With