Shut Down WSL Running Linux Distributions

Here are different ways to shut down Linux systems running inside Windows with WSL.

So you are running Linux inside Windows using WSL. And you are wondering how you can shut down the Linux distribution running in WSL.

You can surely try the shutdown command from within the Linux system running in WSL:

sudo shutdown now

You can also shut down Linux systems using WSL commands. It's an excellent method if you have more than one distro running is WSL.

Shutdown Linux in WSL using Windows Terminal

In this method, I assume that the usual shutdown command doesn't work in WSL Linux Systems.

First, open a terminal in windows. Here, I am using Windows 11 with an Ubuntu setup under WSL 2.

Open a terminal by searching for it on the Windows 11 Start menu
Open a Windows Terminal
πŸ’‘
You can use the wsl command on a standard Windows terminal. The command is also accessible inside a running Linux distribution. Here, the name of the command is wsl.exe.

Now, you need to list what distros are installed and what are their status. To do this, enter:

wsl --list --verbose

OR

wsl -l -v
List all the installed WSL Linux Distribution and their current status.
List Installed Distributions

Here, you can see that, I have one installed WSL Ubuntu, which is currently running.

Shutdown all running Linux distributions

There may be times, when you want to stop app the running WSL instances in one go.

In Powershell or Windows Terminal, use this command:

wsl --shutdown

This will shut down all sessions.

Also, you can perform the same function inside any running WSL Linux Distribution terminal. You just need to use wsl.exe instead of wsl, while working inside a distribution.

wsl.exe --shutdown
Shutting down all running WSL distributions from within another WSL Linux distribution
Shut Down All Running WSL Distributions

Once you run this command, all the running WSL distributions will be terminated. The WSL 2 lightweight utility virtual machine is also terminated. So it will be useful, if you want to restart the WSL 2 virtual machine environment.

Terminate a particular Linux distribution

To terminate a particular running WSL distribution, open a separate Windows terminal and run:

wsl --terminate <Distribution Name>

Here, the distribution name is the one you get, when you list all the installed WSL distributions using the wsl -l -v ⁣ command.

List the WSL distributions
List WSL Distributions
wsl --terminate Ubuntu

Once executed, the specified Linux distribution will be terminated.

If you are inside another distribution, list all the WSL distros installed on your system using:

wsl.exe -l -v

Now, terminate the required distro using:

wsl.exe --terminate <Distribution name>
Shutting Down another WSL Distribution from a running WSL distribution
Shutting down a WSL Distribution from inside another

Conclusion

Some people just close the running Linux application but I don't think that's very graceful.

Also, like a Linux terminal, you can either use:

  • The logout command, to close that distro.
  • The exit command to quit that terminal running the Linux distro.
  • Or, press CTRL+D to do the same as exit command.

But the WSL way of shutting down Linux system has the added advantage of doing it for multiple Linux systems.

I hope it helps you.

About the author
Sreenath

Sreenath

Linux tinkerer by day, Lord of the Rings fanatic by night. When I'm not busy conquering the command line, you can find me kicking back and watching some football while quoting JRR Tolkien

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.