Your Search Bar For Shrewd Tips

How To Close Wsl2


If a Windows Subsystem for Linux 2 (WSL2) distribution is using memory, running background processes, or behaving unexpectedly, you may want to close it completely. Simply closing a Linux terminal window does not always stop every process or shut down the WSL2 virtual machine. The right method depends on whether you want to stop one distribution or all of WSL2. This guide explains how to close WSL2 from Command Prompt or PowerShell, how to check which distributions are running, and what to do if WSL2 starts again afterward.

What Does It Mean to Close WSL2?

WSL2 runs Linux in a lightweight virtual machine managed by Windows. You can have one or more Linux distributions installed, such as Ubuntu, Debian, or Kali Linux. Each distribution can run processes independently, while WSL2 manages the underlying virtual machine.

Closing a terminal window ends that particular shell session, but other Linux processes may continue running. For example, a server, scheduled task, or system service can keep a distribution active after you close the window. Windows may also keep the WSL2 virtual machine available briefly so it can start Linux faster next time.

For a full shutdown, use the WSL command-line tools. You can stop a single distribution or shut down every running WSL distribution and the WSL2 virtual machine.

How to Close All WSL2 Distributions

The quickest way to close WSL2 completely is to run wsl --shutdown. This command stops all running WSL distributions and shuts down the WSL2 virtual machine. It is useful when you want to release WSL2 resources, apply certain configuration changes, or start again with a clean environment.

To shut down WSL2 from Command Prompt or PowerShell:

  • Save your work in every Linux application and terminal.
  • Open Windows Terminal, Command Prompt, or PowerShell. Administrator access is not usually required.
  • Enter the shutdown command below and press Enter.
wsl --shutdown

The command normally finishes without displaying a confirmation message. Any Linux processes that were still running are stopped, so save files and stop important services first. You can reopen your distribution by launching it from the Start menu or running wsl in a Windows terminal.

Use this command when your goal is to close all of WSL2, not just one Linux session. It shuts down every running WSL distribution, including distributions you may have opened in separate terminal windows.

How to Stop One WSL2 Distribution

If you want to keep other Linux distributions running, terminate only the one you no longer need. First, find its registered name. Run this command in Command Prompt or PowerShell:

wsl --list --verbose

You may also use the shorter form:

wsl -l -v

The results show your installed distributions, their status, and their WSL version. A status of Running means that distribution is active. Use the exact name shown in the list with the terminate command:

wsl --terminate Ubuntu

Replace Ubuntu with the name of your distribution. For example, if the list shows Debian, run wsl --terminate Debian. The shorter command is wsl -t followed by the distribution name:

wsl -t Debian

Terminating a distribution stops its running Linux processes, so save your work first. Other distributions remain available and can continue running. If your goal is to shut down the WSL2 virtual machine as well, use wsl --shutdown instead.

How to Check Whether WSL2 Is Still Running

After shutting down or terminating a distribution, you can check its status with:

wsl --list --running

This command lists distributions that are currently running. If the list is empty, no WSL distributions are active at that moment. You can also run wsl --list --verbose to see all registered distributions and whether each one is running or stopped.

Keep in mind that starting a Linux app, opening a distribution, or using a Windows application connected to WSL can launch WSL again. If you run a command that invokes Linux after shutting it down, Windows may start the virtual machine automatically.

Does Closing the Linux Window Shut Down WSL2?

Not necessarily. Closing a terminal window ends the shell running in that window, but it does not guarantee that the distribution or the WSL2 virtual machine has stopped. Other terminal sessions, background jobs, or Linux services may still be active.

If you only want to finish a normal shell session, type exit or close the window. If you want to make sure the distribution stops, use wsl --terminate <DistributionName>. To stop all distributions and shut down the WSL2 virtual machine, use wsl --shutdown.

This distinction matters when troubleshooting, freeing resources, or confirming that a Linux service is no longer running. Closing the window is convenient for ending a session; the WSL commands provide more direct control over the distribution’s running state.

Why WSL2 May Start Again After You Shut It Down

Running wsl --shutdown stops WSL2, but it does not prevent Windows or another application from starting it again. This behavior is normal if something requests access to a Linux distribution.

  • A Linux terminal or app is reopened: Starting Ubuntu or another distribution launches WSL again.
  • A background service is configured to run: A Linux service, including one managed through systemd, may start when its distribution launches.
  • Docker Desktop uses WSL2: Docker Desktop can use WSL2 for its engine or connect to a WSL distribution. Starting Docker Desktop may therefore start WSL components.
  • A Windows tool accesses Linux files or commands: A program that invokes WSL can trigger a new WSL session.

If WSL2 returns immediately, check which applications are open and whether Docker Desktop or another development tool is running. You can shut down WSL2 again, but if an application continues requesting it, the virtual machine may start again until that application is closed or reconfigured.

How to Close WSL2 When It Uses Too Much Memory

When WSL2 is active, Windows may show a process such as VmmemWSL in Task Manager. This process represents resources used by the WSL2 virtual machine. To release those resources, close important Linux work and run:

wsl --shutdown

Then wait briefly and check Task Manager again. The process may disappear or its resource use may drop once the virtual machine has stopped. If it remains or returns, check whether a distribution, Docker Desktop, or another application has started WSL again.

Avoid ending VmmemWSL directly in Task Manager as your usual shutdown method. The WSL command is the supported way to stop the virtual machine cleanly. Also remember that memory use while WSL2 is running is not always a sign of a problem; the Linux environment may use memory for active processes or caching.

Using WSL Commands in PowerShell or Command Prompt

You can run WSL management commands from either PowerShell or Command Prompt. You do not have to open a Linux shell first. For example, these commands work from a Windows terminal:

  • wsl --list --verbose displays installed distributions and their status.
  • wsl --list --running displays distributions that are running now.
  • wsl --terminate Ubuntu stops the named distribution.
  • wsl --shutdown stops all running distributions and the WSL2 virtual machine.

If Windows says that wsl is not recognized, confirm that WSL is installed and that you are using a supported Windows version. You can also open Windows Terminal and try the command from a new PowerShell or Command Prompt tab. On managed work or school devices, an administrator may control whether WSL is available.

What to Do if WSL2 Will Not Close

If a shutdown appears unsuccessful, confirm that you typed wsl --shutdown correctly and run it from a Windows command prompt rather than inside a Linux-only shell. Then check the status with wsl --list --running. If no distributions are listed but WSL starts again, another application is likely reopening it.

Close applications that use WSL, such as Linux terminals, development environments, and Docker Desktop, then run the shutdown command again. If the issue continues, save your work and restart Windows. A restart can clear a stuck WSL session, but it should not be your first choice when the normal shutdown command works.

Do not use wsl --unregister as a way to close a distribution. That command removes the distribution and deletes its Linux data, which is very different from stopping it. Use wsl --terminate or wsl --shutdown when you only want to close WSL2 temporarily.

Which WSL2 Shutdown Method Should You Use?

Choose the command based on what you want to stop. If you only need to end the shell you are using, type exit or close its terminal window. If one distribution needs to stop while others remain available, use wsl --terminate with that distribution’s exact name. If you want to close everything running under WSL2, use wsl --shutdown.

  • Close one terminal session: Type exit or close the window.
  • Stop one Linux distribution: Run wsl --terminate <DistributionName>.
  • Stop all distributions and the WSL2 virtual machine: Run wsl --shutdown.
  • Check the current status: Run wsl --list --verbose or wsl --list --running.

Conclusion

To close WSL2 completely, save your Linux work and run wsl --shutdown from PowerShell, Command Prompt, or Windows Terminal. To stop just one distribution, use wsl --terminate with its name. You can confirm the result with wsl --list --running.

Closing a terminal window alone may not stop background processes, and applications such as Docker Desktop can start WSL2 again. Knowing the difference between ending a shell, terminating one distribution, and shutting down the entire WSL2 virtual machine makes it easier to manage Linux processes and Windows resources safely.


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 →