Closing Command Prompt

Maintained on
Table of Contents

When working with Command Prompt, it is important to first learn how to exit it.

This page introduces four methods to close Command Prompt.

Quick reference

GoalHow
Exit using only the keyboardType exit and press Enter
Close the window immediatelyAlt + F4 or the × button
Stop a running command (keep the window)Ctrl + C
Stop a command that will not stopCtrl + Break, or taskkill from another window
Exit at the end of a batch fileexit (use exit /b to leave only the batch file)

Close with × Button

This method is common to other windows in Windows, but you can close Command Prompt by clicking the × button in the upper right corner of the Command Prompt window.

This is the button in the upper right corner of the sample below.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>

When you close Command Prompt this way, commands running in it are terminated as well. However, processes launched as separate windows or GUI apps, for example with the start command, may keep running after Command Prompt is closed.

If a process could cause problems when terminated midway (such as file writing), it is recommended to wait until the process completes normally or terminate it using an appropriate method.

Close from Right-Click Menu

This method is also common to other windows in Windows. Right-clicking the title bar of the Command Prompt window displays a context menu.

Clicking “Close” in that menu will close Command Prompt.

Also, right-clicking the icon in the upper left corner of the window displays the same menu. This menu can also be displayed with Alt + Space.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>

Close with exit Command

Command Prompt has an exit command that ends the session (cmd.exe).

You can close Command Prompt by executing this command.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>exit

When you execute the above command, cmd.exe terminates and the window closes.

For details on the exit command, please refer to the following page.

Close with Alt + F4

With the Command Prompt window active, pressing Alt + F4 will close Command Prompt.

Similar to the first method, running commands are terminated as well, so if something is still running, wait for it to finish or interrupt it with Ctrl + C before closing.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>

Stop a Running Command Before Closing

While a command is running, press Ctrl + C to interrupt it first. Once the prompt returns, type exit.

For an unresponsive command, find the process with tasklist from another Command Prompt and end it with taskkill (add /F to force it).

Inside a batch file, exit closes the whole Command Prompt, while exit /b ends only the batch file and returns to the caller.

Summary

There are four methods to close Command Prompt as described above.

If something is still running, wait for it to finish or interrupt it with Ctrl + C before closing.

Also, methods other than the exit command are common to other windows in Windows, so it’s useful to remember them.

#Command Prompt #Batch File #Arguments #Command Line #Command