I've been stopping commands with the trash can for too long. Command period doesn't work on Mac. I can't find anywhere how to stop the terminal via a command. What is it?
14 Answers
You can terminate with the Trash icon like you do, or press Ctrl + C. That's the shortcut from the default Terminal application and it also works in Visual Studio Code.

- 30,738
- 21
- 105
- 131

- 1,213
- 9
- 4
-
6thats crazy. i had done command C in the past, and totally missed that it was control lol – faceyspacey.com Aug 17 '17 at 16:11
-
1Cmd + c is obvious, but it doesn't work. Nothing happens. I am using karabiner app, so... maybe this is the reason?.. – John Smith Oct 28 '19 at 21:01
-
@JohnSmith same with me. did you find any solution? – Mehul Parmar Nov 10 '21 at 16:41
-
@MehulParmar, unfortunately, no. Just close/open the whole terminal. – John Smith Nov 11 '21 at 12:45
-
Is that simple?! thanks alot best way to stop running code in terminal – Hello-experts Nov 18 '21 at 18:48
-
This only worked for me after disabling key chords in the terminal. You can find this setting by pressing Ctrl+Shift+P, then search for "Preferences: open user settings", and look under User >> Features >> Terminal and uncheck the mark under "Terminal > Integrated: Allow Chords" – Martin Apr 07 '22 at 20:49
-
Wrong on both fronts. The trash can icon does not kill the running process. It just makes that terminal window go away inside VS Code. The process will continue to run in the background. Also by default, the keyboard shortcut Ctrl+C in the VS Code terminal is just "copy". – still_dreaming_1 Apr 05 '23 at 22:35
-
@JohnSmith I found this key mapping for karabiner that does the trick, I still needed to do a simple mapping of left ctrl + c => left cmd + c, but now my right ctrl + c (and other combos) works as expected. https://github.com/rux616/karabiner-windows-mode – Nick Jul 20 '23 at 22:43
Ctrl + C works in the terminal, but it didn't work for me in Visual Studio Code. However, hitting Q did (when running a git diff
for example).

- 30,738
- 21
- 105
- 131

- 789
- 1
- 9
- 22
-
-
This is not an answer to the question. You are just describing how `git diff` processes the Q key. The question is not about `git diff`, it's about VSCode. – still_dreaming_1 Apr 05 '23 at 22:37
In certain cases, such as running a Node.js server, Ctrl + C wouldn't work. Instead, you can stop the app or command by pressing Ctrl + Alt + M (i.e., Ctrl + Option + M for Mac users).
Sample JavaScript code to demonstrate this:
const http = require('http');
http.createServer((req, res) => {
res.write('Hello, World!!');
res.end();
}).listen(5000, () => console.log('Server running...'));

- 30,738
- 21
- 105
- 131

- 488
- 1
- 9
- 22
If you are on Linux, open the shortcuts:
Then type kill, and this option will appear.
Double-click on the record, choose a shortcut for it, open the terminal, Ctrl + J, and press the shortcut you chose.
The difference in pressing Ctrl + J and then Ctrl + J again to close, is that it will not keep the terminal process, but only close it.

- 30,738
- 21
- 105
- 131

- 381
- 5
- 11
Neither Ctrl + C nor the trash icon actually stopped the server for me.
If you are using the Live Server extension by Ritwick Day, there should be a label on the bar at the bottom for the status of the server.
If it reads Port: 5500
it means it's running. Just click on it to stop it.
The same label now should say Go Live. Click on it in order to do exactly that.

- 30,738
- 21
- 105
- 131

- 21
- 4
Many Mac users (including me) get confused with the Cmd and Ctrl keys. But Ctrl + C should work fine.

- 30,738
- 21
- 105
- 131

- 31
- 1
- 6
Hitting Esc clears out the terminal and cancels everything.

- 30,738
- 21
- 105
- 131

- 19
- 1
You can stop any running command by pressing Ctrl + C on your keyboard.

- 30,738
- 21
- 105
- 131

- 111
- 1
- 11
If it is ':' you see, then Q + Enter.
For example: git config --list
(this will take you to the colon(':') and you may not be able to escape this)

- 7,295
- 4
- 71
- 112
In Visual Studio (2022) the shortcut may actually Ctrl+Pause/Break instead of Ctrl+C.

- 1,862
- 2
- 21
- 35
In Visual Studio Code, first hit Ctrl + C.
It will ask the following question;
Terminate batch job (Y/N)?
Press Y + Enter.
After this, run the following command on the prompt:
exit + <Enter>
It will stop the instance.

- 30,738
- 21
- 105
- 131

- 1
- 2
You can kind of bypass the issue by writing system("pause") at the very end of your main function. That works for me like a charm...

- 30,738
- 21
- 105
- 131

- 1
- 1
POSIX signals should work - ctrl+c
(SIGINT
) usually works, but occasionally I find I need something more powerful - ctrl+\
(SIGQUIT
- "terminate the application dumping core") usually does it.
SIGKILL
is even more brutal, and generally not advisable as it can cause system instability, and there is not usually a shortcut set up for that in most shells.

- 2,061
- 24
- 17