Powering it off

How to shutdown WSL 2 Linux distros on Windows 10

If you use WSL 2 on Windows 10, you can use a couple of commands to shut down one or all Linux distros manually, and here's how.

WSL 2 shutdown Linux distros

Although the Windows Subsystem for Linux (WSL) is a convenient way to run Linux distros alongside Windows 10, the lightweight virtual machine will continue to run in the background, wasting system resources even when you exit the command shell.

If you prefer to terminate the Linux distro (Ubuntu, Kali, Debian, etc.) as soon as you are done using it, or you need to restart it, you can use a wsl command to shut down one or all distributions manually.

In this guide, you will learn the steps to shut down Linux distros running in the Windows Subsystem for Linux 2 (WSL2) platform on Windows 10.

How to terminate a Linux distro on WSL 2

To terminate a Linux distro on Windows Subsystem for Linux, use these steps:

  1. Open Start.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. Type the following command to view all running WSL distros and press Enter:

    wsl --list --verbose
  4. Type the following command to shut down the Linux distribution and press Enter:

    wsl -t DISTRO-NAME
    WSL terminate Linux distro command
    WSL terminate Linux distro command

    In the command, make sure to replace DISTRO-NAME with the name of the distro you want to shut down as shown on step No. 3. For example, wsl -t Ubuntu-20.04.

  5. (Optional) Type the following command to confirm the distro is no longer running and press Enter

    wsl --list --verbose

Once you complete the steps, the distro running on the Windows Subsystem for Linux 2 will gracefully shut down. You can always repeat the steps to terminate other distros or use the steps below to shut them all down.

How to terminate all Linux distros on WSL 2

To shut down all the WSL distros running on Windows 10, use these steps:

  1. Open Start.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. Type the following command to view all running WSL distros and press Enter:

    wsl --list --verbose
  4. Type the following command to shut down the Linux distribution and press Enter:

    wsl --shutdown

    WSL shutdown all Linux distros command
    WSL shutdown all Linux distros command
  5. (Optional) Type the following command to confirm the distro is no longer running and press Enter:

    wsl --list --verbose

After you complete the steps, all the WSL distros will terminate immediately.

If you need to restart the Linux distro, simply open it again from the Start menu or in Command Prompt using the wsl --distribution DISTRO-NAME command. Remember to replace the DISTRO-NAME with the actual name of the distro.