How do I close the Terminal in OSX from the command line?
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?
macos command-line terminal exit
migrated from stackoverflow.com Jun 29 '10 at 23:18
This question came from our site for professional and enthusiast programmers.
add a comment |
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?
macos command-line terminal exit
migrated from stackoverflow.com Jun 29 '10 at 23:18
This question came from our site for professional and enthusiast programmers.
Command + q
will close the window
– Kolob Canyon
Nov 26 '16 at 15:43
add a comment |
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?
macos command-line terminal exit
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?
macos command-line terminal exit
macos command-line terminal exit
edited Nov 15 '12 at 14:20
Florenz Kley
1,393617
1,393617
asked Jun 29 '10 at 2:11
user242065
migrated from stackoverflow.com Jun 29 '10 at 23:18
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jun 29 '10 at 23:18
This question came from our site for professional and enthusiast programmers.
Command + q
will close the window
– Kolob Canyon
Nov 26 '16 at 15:43
add a comment |
Command + q
will close the window
– Kolob Canyon
Nov 26 '16 at 15:43
Command + q
will close the window– Kolob Canyon
Nov 26 '16 at 15:43
Command + q
will close the window– Kolob Canyon
Nov 26 '16 at 15:43
add a comment |
6 Answers
6
active
oldest
votes
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
- always close the window, whatever the exit status of the shell was
- close the window if the shell exited cleanly
- 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.
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of theexit
command which the OP was using originally.
– jdersen
Dec 22 '18 at 3:57
add a comment |
Command + Q -> closes the application/process.
Command + W -> closes window/instance
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
add a comment |
Yes there is. For example you can use AppleScript to achieve it:
osascript -e 'tell application "Terminal" to close first window'
The first window is always the currently active window. That's the one you want to close.
Before closing the window, the Terminal may ask you, if you really want to close the window.
This depends on your settings. You may have chosen to 'close the window only if the shell exited cleanly or no other processes are running apart from …'. (This may be the default setting.)
In that case adding & exit
to the command closes the window immediately and without asking.
osascript -e 'tell application "Terminal" to close first window' & exit
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
add a comment |
I also suggest against the killall suggestion. As suggested modify the settings in your preferences to close window if shell exit was successful. If you're REALLY LAZY (like me), open up your bash profile and add an alias. I have mine set so all I have to do is type 'q'.
add a comment |
Actually, for this requirement, you should set some config to your Terminal. follow below instructions and you will close your Terminal just with an exit
command.
When the Terminal is up, press ⌘+, to open the prefrences window. 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.
Your Terminal is ready for the exit just with an exit
command.
add a comment |
If you want to terminate the application itself from the commandline:
killall Terminal
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f158375%2fhow-do-i-close-the-terminal-in-osx-from-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
- always close the window, whatever the exit status of the shell was
- close the window if the shell exited cleanly
- 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.
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of theexit
command which the OP was using originally.
– jdersen
Dec 22 '18 at 3:57
add a comment |
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
- always close the window, whatever the exit status of the shell was
- close the window if the shell exited cleanly
- 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.
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of theexit
command which the OP was using originally.
– jdersen
Dec 22 '18 at 3:57
add a comment |
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
- always close the window, whatever the exit status of the shell was
- close the window if the shell exited cleanly
- 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.
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
- always close the window, whatever the exit status of the shell was
- close the window if the shell exited cleanly
- 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.
edited Nov 15 '12 at 14:20
Florenz Kley
1,393617
1,393617
answered Jun 29 '10 at 2:19
Amadan
1,290911
1,290911
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of theexit
command which the OP was using originally.
– jdersen
Dec 22 '18 at 3:57
add a comment |
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of theexit
command which the OP was using originally.
– jdersen
Dec 22 '18 at 3:57
10
10
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
In Yosemite it's: preferences -> profiles -> shell -> "when the shell exits"... Shell is whichever shell you have selected in General-> On startup open...
– cloudsurfin
Sep 22 '15 at 17:21
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
Once the shell is exited, is it possible to start a new shell in the same window? If so, how?
– Sodved
Jul 9 '16 at 2:14
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
@Sodved: I don't think it is, but could be wrong.
– Amadan
Jul 11 '16 at 5:34
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of the
exit
command which the OP was using originally.– jdersen
Dec 22 '18 at 3:57
@ChrisStratton You're correct that it does not directly answer the question asked, but it does facilitate the use of the
exit
command which the OP was using originally.– jdersen
Dec 22 '18 at 3:57
add a comment |
Command + Q -> closes the application/process.
Command + W -> closes window/instance
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
add a comment |
Command + Q -> closes the application/process.
Command + W -> closes window/instance
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
add a comment |
Command + Q -> closes the application/process.
Command + W -> closes window/instance
Command + Q -> closes the application/process.
Command + W -> closes window/instance
edited Sep 24 '17 at 22:20
Nisse Engström
22737
22737
answered Jun 29 '10 at 2:23
prem
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
add a comment |
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
This does not answer the question that was asked, as it does not propose a command line operation.
– Chris Stratton
Jan 4 '17 at 17:59
add a comment |
Yes there is. For example you can use AppleScript to achieve it:
osascript -e 'tell application "Terminal" to close first window'
The first window is always the currently active window. That's the one you want to close.
Before closing the window, the Terminal may ask you, if you really want to close the window.
This depends on your settings. You may have chosen to 'close the window only if the shell exited cleanly or no other processes are running apart from …'. (This may be the default setting.)
In that case adding & exit
to the command closes the window immediately and without asking.
osascript -e 'tell application "Terminal" to close first window' & exit
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
add a comment |
Yes there is. For example you can use AppleScript to achieve it:
osascript -e 'tell application "Terminal" to close first window'
The first window is always the currently active window. That's the one you want to close.
Before closing the window, the Terminal may ask you, if you really want to close the window.
This depends on your settings. You may have chosen to 'close the window only if the shell exited cleanly or no other processes are running apart from …'. (This may be the default setting.)
In that case adding & exit
to the command closes the window immediately and without asking.
osascript -e 'tell application "Terminal" to close first window' & exit
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
add a comment |
Yes there is. For example you can use AppleScript to achieve it:
osascript -e 'tell application "Terminal" to close first window'
The first window is always the currently active window. That's the one you want to close.
Before closing the window, the Terminal may ask you, if you really want to close the window.
This depends on your settings. You may have chosen to 'close the window only if the shell exited cleanly or no other processes are running apart from …'. (This may be the default setting.)
In that case adding & exit
to the command closes the window immediately and without asking.
osascript -e 'tell application "Terminal" to close first window' & exit
Yes there is. For example you can use AppleScript to achieve it:
osascript -e 'tell application "Terminal" to close first window'
The first window is always the currently active window. That's the one you want to close.
Before closing the window, the Terminal may ask you, if you really want to close the window.
This depends on your settings. You may have chosen to 'close the window only if the shell exited cleanly or no other processes are running apart from …'. (This may be the default setting.)
In that case adding & exit
to the command closes the window immediately and without asking.
osascript -e 'tell application "Terminal" to close first window' & exit
edited Sep 24 '17 at 22:20
Nisse Engström
22737
22737
answered Jan 13 '15 at 10:29
Thomas.S
9111
9111
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
add a comment |
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
This is almost right, but in actuality the "first window" is not always the one running the command.
– Chris Stratton
Jan 4 '17 at 18:41
add a comment |
I also suggest against the killall suggestion. As suggested modify the settings in your preferences to close window if shell exit was successful. If you're REALLY LAZY (like me), open up your bash profile and add an alias. I have mine set so all I have to do is type 'q'.
add a comment |
I also suggest against the killall suggestion. As suggested modify the settings in your preferences to close window if shell exit was successful. If you're REALLY LAZY (like me), open up your bash profile and add an alias. I have mine set so all I have to do is type 'q'.
add a comment |
I also suggest against the killall suggestion. As suggested modify the settings in your preferences to close window if shell exit was successful. If you're REALLY LAZY (like me), open up your bash profile and add an alias. I have mine set so all I have to do is type 'q'.
I also suggest against the killall suggestion. As suggested modify the settings in your preferences to close window if shell exit was successful. If you're REALLY LAZY (like me), open up your bash profile and add an alias. I have mine set so all I have to do is type 'q'.
answered Apr 13 '14 at 17:40
bran.io
41115
41115
add a comment |
add a comment |
Actually, for this requirement, you should set some config to your Terminal. follow below instructions and you will close your Terminal just with an exit
command.
When the Terminal is up, press ⌘+, to open the prefrences window. 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.
Your Terminal is ready for the exit just with an exit
command.
add a comment |
Actually, for this requirement, you should set some config to your Terminal. follow below instructions and you will close your Terminal just with an exit
command.
When the Terminal is up, press ⌘+, to open the prefrences window. 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.
Your Terminal is ready for the exit just with an exit
command.
add a comment |
Actually, for this requirement, you should set some config to your Terminal. follow below instructions and you will close your Terminal just with an exit
command.
When the Terminal is up, press ⌘+, to open the prefrences window. 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.
Your Terminal is ready for the exit just with an exit
command.
Actually, for this requirement, you should set some config to your Terminal. follow below instructions and you will close your Terminal just with an exit
command.
When the Terminal is up, press ⌘+, to open the prefrences window. 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.
Your Terminal is ready for the exit just with an exit
command.
answered Dec 18 '18 at 7:25
AmerllicA
1012
1012
add a comment |
add a comment |
If you want to terminate the application itself from the commandline:
killall Terminal
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
add a comment |
If you want to terminate the application itself from the commandline:
killall Terminal
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
add a comment |
If you want to terminate the application itself from the commandline:
killall Terminal
If you want to terminate the application itself from the commandline:
killall Terminal
answered Jun 30 '10 at 0:06
Just Jake
633417
633417
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
add a comment |
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
4
4
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
that is considered harmful. Apart from the fact tha killall does different things on different Unix versions, it's not nice to kill an application instead of asking it to just quit.
– Florenz Kley
Nov 15 '12 at 13:55
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f158375%2fhow-do-i-close-the-terminal-in-osx-from-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Command + q
will close the window– Kolob Canyon
Nov 26 '16 at 15:43