If you are wondering how to close a WSL terminal, the right method depends on whether you want to exit the current shell, close a terminal tab, or stop a Linux distribution running in the background. For a normal session, type exit or press Ctrl+D. To close only the window or tab, use its close button. To stop a WSL distribution completely, run a WSL command from Windows PowerShell or Command Prompt. This guide explains each option and when to use it on Windows 10 and Windows 11.
Quick Ways to Close a WSL Terminal
Choose the action that matches what you want to close. These methods are related, but they do not all do the same thing:
-
Exit the current Linux shell: Type
exitand press Enter, or pressCtrl+D. - Close a terminal tab or window: Select the tab’s close button or close the terminal application.
-
Stop one WSL distribution: Run
wsl --terminate <DistributionName>in PowerShell or Command Prompt. -
Stop all WSL distributions: Run
wsl --shutdownin PowerShell or Command Prompt.
For everyday use, exiting the shell is usually enough. Use a termination command when you specifically need to stop Linux processes or free resources used by WSL.
Method 1: Type Exit in the WSL Terminal
The simplest way to close a WSL terminal session is to enter exit at the Linux prompt:
exit
Press Enter after typing the command. This ends the current shell. If it is the only shell running in that terminal tab, the session ends and the terminal may show a message such as “The process exited” or return to a prompt from the application that launched WSL. Depending on your terminal settings, the tab may close automatically or remain open until you close it yourself.
This method works in common Linux shells, including Bash and Zsh. You can also use logout in a login shell, although exit is the more familiar and broadly useful option. If you opened a nested shell—for example, by typing bash from another shell—exit closes only the current shell. You may need to enter it again to leave each remaining shell layer.
Method 2: Press Ctrl+D
Ctrl+D sends an end-of-file signal to the shell. At an idle command prompt, this usually has the same practical effect as typing exit: the current shell closes. It is a quick keyboard shortcut when you do not want to type a command.
The shortcut depends on what the terminal is doing. If a program is currently accepting input, Ctrl+D may send that program an end-of-file signal instead of closing the shell. For example, it can finish input in some command-line tools. If nothing happens, or if you are unsure whether the program has ended, press Ctrl+C to interrupt the current command, wait for the shell prompt, and then type exit.
Method 3: Close the Terminal Tab or Window
If your goal is simply to dismiss the WSL terminal from view, close its tab or window using the terminal application’s controls. In Windows Terminal, select the X on the active tab or use the window’s close button. Keyboard shortcuts can vary by application and by customized settings, so check the application’s menu if you want to use a shortcut.
Closing a terminal tab ends the foreground session associated with that tab, but it is not always the clearest way to manage background Linux processes. A command, service, or other process that was started to continue running may behave differently from a command running interactively in the shell. If you need to ensure that a distribution stops, use wsl --terminate or wsl --shutdown from Windows instead.
When you close a terminal window, any unsaved work in command-line programs may be lost. Save files, finish edits, and stop important tasks before closing the tab. If a program asks for confirmation, follow its prompt rather than forcing the window closed.
How to Stop a WSL Distribution Completely
Exiting a shell and stopping a WSL distribution are different actions. A distribution may remain available or continue running processes even after you leave a particular shell. To stop a specific distribution, open PowerShell or Command Prompt in Windows and run:
wsl --terminate <DistributionName>
Replace <DistributionName> with the installed distribution’s actual name. For example:
wsl --terminate Ubuntu
If you are not sure what name to use, list your installed distributions from PowerShell or Command Prompt:
wsl --list --verbose
The output shows each distribution’s name and status. Copy the name exactly as it appears, then use it with wsl --terminate. Terminating a distribution stops its running processes and ends its current WSL session. Save your work first, since programs that are still running may be interrupted.
How to Shut Down All WSL Distributions
To stop every running WSL distribution, run this command in PowerShell or Command Prompt:
wsl --shutdown
This is useful if you want to end all WSL activity, troubleshoot a distribution, or release resources being used by the WSL environment. It applies to all running distributions, not just the one visible in your current terminal. Save work in every WSL session before using it, because active processes will be stopped.
Running wsl --shutdown closes the WSL environment; it does not uninstall your Linux distributions or delete their files. You can start WSL again by opening a distribution from the Start menu or launching it with a command such as wsl in Windows Terminal.
Closing WSL in Windows Terminal
Windows Terminal can run several tabs, including multiple WSL distributions and PowerShell sessions. Closing one tab does not necessarily close the other tabs. Select the WSL tab you want to close, then use the tab’s close control. If the tab contains a running shell, Windows Terminal may ask you to confirm before ending it.
If you only want to hide the terminal temporarily, minimize the window rather than closing the tab. If you want to end the Linux shell but keep Windows Terminal open, type exit in the WSL tab. You can then use the plus button or the tab menu to open another shell or distribution.
For a reliable full shutdown, run wsl --shutdown in a separate PowerShell or Command Prompt tab. Keeping the Windows Terminal application open does not prevent you from stopping WSL; the two are separate.
Closing WSL in Visual Studio Code
If you are using WSL through Visual Studio Code, the integrated terminal is only one part of the development setup. To close a terminal session, focus the terminal panel and select the trash-can icon for that terminal. You can also type exit at its shell prompt. The terminal panel can be hidden without ending the shell, so hiding it is not the same as closing the session.
Closing the integrated terminal does not necessarily close your VS Code window or disconnect every WSL-related feature. For example, a VS Code window opened in a WSL workspace can remain open after its terminal is closed. If you want to stop the entire distribution, use wsl --terminate <DistributionName> or wsl --shutdown from Windows.
What to Do If the WSL Terminal Will Not Close
A terminal may seem stuck because a command is still running, a program is waiting for input, or the shell is not at its prompt. Try these steps in order:
-
Interrupt the current command: Press
Ctrl+Conce and wait for the Linux prompt. This interrupts many foreground commands but does not close WSL by itself. -
Exit the shell: At the prompt, type
exitand press Enter. - Close the tab: Use the terminal application’s close control if you only need to dismiss that session.
-
Terminate the distribution: From PowerShell or Command Prompt, run
wsl --terminate <DistributionName>. -
Shut down WSL: If you need to stop all distributions, run
wsl --shutdown.
Do not use Ctrl+C as your only shutdown method if the goal is to stop the entire distribution. It sends an interrupt to the foreground process, and some programs may ignore it or handle it differently.
Does Closing the WSL Terminal Delete Your Files?
No. Exiting a shell, closing a terminal tab, terminating a distribution, or shutting down WSL does not normally delete the files stored in that distribution. Your Linux files remain available when you start the distribution again. However, closing a session can interrupt running work, and unsaved changes inside an editor or command-line program may be lost.
Before stopping WSL, save documents and check for long-running tasks such as downloads, builds, or data processing. If a task must continue, confirm that it is designed to run in the background and that closing your session will not interrupt it.
Which WSL Closing Method Should You Use?
Use the least disruptive option that meets your needs. If you have finished working in one shell, type exit. If you only want to close a visible tab, use the tab’s close button. If a specific Linux distribution needs to stop, use wsl --terminate with its name. Choose wsl --shutdown when you want all WSL distributions to stop.
Remember that the terminal application and WSL are not the same thing. Closing a window manages the interface; exiting a shell ends that shell; and WSL shutdown commands control the Linux environment. Knowing the difference makes it easier to close WSL safely without interrupting other sessions or work.
Conclusion
The fastest way to close a WSL terminal is to type exit or press Ctrl+D. To close a tab or window, use the terminal’s close control. If you need to stop a Linux distribution, run wsl --terminate <DistributionName> from Windows, or use wsl --shutdown to stop all running distributions. Save your work before ending active sessions, and choose the method that matches whether you want to close the shell, the window, or WSL itself.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.