Your Search Bar For Shrewd Tips

How To Close Wsl


If you use Windows Subsystem for Linux (WSL), closing a Linux terminal window does not always stop the Linux distribution or its background processes. To fully close WSL, you can shut down every running distribution or stop one specific distribution from Windows Terminal, PowerShell, or Command Prompt. This guide explains how to close WSL safely, check which distributions are running, and troubleshoot common shutdown questions.

How to Close WSL Completely

The quickest way to stop all running WSL distributions is to run wsl --shutdown in a Windows command-line tool. This shuts down every running distribution and the WSL 2 virtual machine. Use it when you want to close WSL completely, free resources, or restart the WSL environment.

  1. Save your work in any open Linux applications or terminal sessions.
  2. Open Windows Terminal, PowerShell, or Command Prompt.
  3. Enter the following command and press Enter:

wsl --shutdown

The command normally returns to the Windows prompt without a confirmation message. To check whether any distributions are still running, enter:

wsl --list --running

If the list is empty, no WSL distributions are currently running. Running a Linux distribution or opening a new WSL terminal starts it again.

How to Close One WSL Distribution

If you have multiple Linux distributions installed, you may want to stop just one and leave the others running. Use wsl --terminate followed by the distribution name.

First, list the distributions installed on your computer and check their names:

wsl --list --verbose

You may see output similar to this:

  NAME            STATE           VERSION
* Ubuntu          Running         2
  Debian          Stopped         2

In this example, you can stop Ubuntu with:

wsl --terminate Ubuntu

Replace Ubuntu with the exact name shown on your computer. Distribution names may include a version number, such as Ubuntu-24.04. After issuing the command, check the status with wsl --list --verbose. The distribution should show as Stopped.

Use wsl --terminate when you want to close a single Linux environment without interrupting other running distributions. Like a full shutdown, terminating a distribution stops its active processes, so save your work first.

How to Find the Name of a Running WSL Distribution

Commands that target a particular distribution need its registered name. To see every installed distribution and its current state, run:

wsl --list --verbose

To display only distributions that are currently running, use:

wsl --list --running

You can also use the shorter list option to display installed distribution names:

wsl --list --quiet

Use the name exactly as it appears in the output. If you are unsure which distribution is using resources, the verbose list is usually the most helpful because it includes both the distribution name and whether it is running or stopped.

How to Close WSL from Windows Terminal, PowerShell, or Command Prompt

You can run WSL shutdown commands from several Windows command-line applications. Open the one you prefer, then enter the command you need:

  • wsl --shutdown stops all running WSL distributions.
  • wsl --terminate <DistributionName> stops one selected distribution.
  • wsl --list --running checks which distributions are running.
  • wsl --list --verbose shows installed distributions and their states.

For example, in PowerShell, you can stop a distribution named Debian with wsl --terminate Debian. In Command Prompt, use the same command. On most up-to-date Windows systems, wsl is available as a command. If Windows does not recognize it, try wsl.exe instead, and check that WSL is installed and enabled.

Does Closing a WSL Window Stop Linux?

Not necessarily. Closing a terminal window ends that terminal session, but it does not always shut down the distribution. Other Linux processes, services, or applications may still be running in the background. That is why a distribution can continue to appear as Running after you close the window where you started it.

If your goal is to stop just one distribution, use wsl --terminate. If you want to stop all WSL activity, use wsl --shutdown. These commands explicitly stop the relevant environment instead of relying on a terminal window closing.

What Happens When You Run WSL --shutdown?

The wsl --shutdown command stops all running distributions and shuts down the WSL 2 virtual machine. This can be useful if a Linux process is stuck, if you need to restart WSL, or if you want WSL to release resources while you are not using it. The next time you open a WSL distribution, Windows starts the environment again.

Because shutdown stops running processes, unsaved work can be lost. Save files and close applications cleanly before using the command whenever possible. Also note that software that depends on WSL, such as a development tool or a container application configured to use WSL, may start WSL again when you use that software.

How to Restart WSL After Closing It

WSL starts automatically when you launch a distribution. After running wsl --shutdown, you can restart your default distribution by entering:

wsl

To start a particular distribution, use its registered name:

wsl --distribution Ubuntu

Replace Ubuntu with the name of your distribution. You can also open the distribution from the Windows Start menu or launch it from Windows Terminal. If you are troubleshooting a temporary problem, shutting down WSL and then starting the distribution again is a simple way to reset the environment.

WSL Shutdown, Terminate, and Unregister: What Is the Difference?

These commands serve different purposes, so choose carefully:

  • wsl --shutdown stops all running distributions and the WSL 2 virtual machine. It does not remove your distributions or their files.
  • wsl --terminate <DistributionName> stops one distribution. It does not uninstall it or delete its files.
  • wsl --unregister <DistributionName> removes a distribution from WSL and deletes its associated data.

Do not use wsl --unregister just to close or stop Linux. It is a removal command, and the associated distribution data may be permanently deleted. For ordinary shutdown, use wsl --shutdown or wsl --terminate.

Why Is WSL Still Running After I Close It?

If a distribution remains active after you close a terminal window, another process may be keeping it running. For example, a background Linux service, an editor connected to WSL, or a container tool may still be using the environment. Check the active distributions with wsl --list --running.

To stop everything currently running under WSL, save your work and run wsl --shutdown. If WSL starts again afterward, check whether an application or service is launching it. Some development workflows automatically start a distribution when you open a project or connect to a Linux environment.

On WSL 2, Windows may also show a process such as VmmemWSL in Task Manager while the virtual machine is active. Running wsl --shutdown stops the WSL 2 virtual machine. Avoid ending system processes in Task Manager as your first troubleshooting step; use the WSL commands designed to stop distributions.

Common WSL Shutdown Problems

If a shutdown command does not work as expected, try these checks:

  • Confirm the command prompt is in Windows. Run wsl --shutdown from PowerShell, Command Prompt, or Windows Terminal using a Windows shell.
  • Check the distribution name. Run wsl --list --verbose and copy the name shown in the list.
  • Use the full executable name. If wsl is not recognized, try wsl.exe --shutdown.
  • Check whether WSL restarted. A development or container application may have started it again. Run wsl --list --running after closing or pausing that application.
  • Restart your computer if necessary. If WSL remains unresponsive after a shutdown attempt, save your work and restart Windows before trying again.

For routine use, shutting down WSL from Windows Terminal or PowerShell is usually enough. You generally do not need to uninstall a distribution, change system settings, or end WSL-related processes manually.

Frequently Asked Questions About Closing WSL

Does wsl --shutdown delete my Linux files?
No. It stops running distributions but does not remove them or delete their files. Avoid wsl --unregister unless you intend to remove a distribution and its data.

Can I close only Ubuntu and keep another distribution running?
Yes. Run wsl --terminate Ubuntu, replacing Ubuntu with the correct name. Other distributions can continue running.

Will WSL start again automatically?
Yes. Launching a distribution or using an application that depends on WSL can start it again after shutdown.

Should I use shutdown or terminate?
Use wsl --shutdown to stop all running distributions. Use wsl --terminate when you only want to stop one.

Conclusion

To close WSL completely, save your work and run wsl --shutdown in Windows Terminal, PowerShell, or Command Prompt. To stop just one Linux distribution, check its name with wsl --list --verbose and run wsl --terminate <DistributionName>. These commands stop WSL without deleting your Linux files. Use wsl --list --running to confirm what is active, and remember that opening a WSL distribution or a connected application can start it again.


Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

Shrewdnia

Shrewdnia

Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

Back to blog

Leave a comment

JOIN THE SHREWDNIA COMMUNITY FORUM

What do you think?

Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

Join the Forum →