Skip to content
Windows

How to Shut Down Ubuntu on Windows 11 Using WSL

Richard
Written by
Richard
Updated 4 min read
How to Enable or Disable Microsoft Defender Cloud Protection
How to Enable or Disable Microsoft Defender Cloud Protection
Before you start
  • 11 steps
  • Needs administrator rights

Shutting down Ubuntu on Windows 11 stops every running Linux task at once and gives the memory and CPU it was using back to Windows. You do it with a single command in PowerShell.

The command works on the Windows Subsystem for Linux (WSL), the built-in Windows feature that lets you run Linux tools directly on your PC. Use it when Ubuntu freezes, when something in the background is eating resources, or when you want to stop all Linux processes in one go. The next time you open Ubuntu, it starts again from scratch. Nothing is uninstalled and none of your files are removed.

⚡ Quick Answer

Run wsl –shutdown in PowerShell or Command Prompt to stop Ubuntu and every other running WSL distribution at once. This frees the memory and CPU they were using. Nothing is uninstalled, and your files stay in place. To stop only Ubuntu, run wsl –terminate Ubuntu instead. Save your work first, because any process still writing to disk will be cut off.

Advertisement

Why shut down Ubuntu WSL?

Closing the terminal window does not always stop Ubuntu. Anything you started in the background keeps running, such as a web server, a database, a tmux session or a script launched with nohup. While those processes run, Ubuntu stays loaded and keeps using memory. That is why you sometimes need to shut it down yourself.

What happens when you are done?

⚠️WarningA full WSL shutdown stops the Linux kernel and halts every background process, so the next start begins from a clean state. It closes every Linux distribution running on your machine, not only Ubuntu. If you have Debian, Kali or another distribution open, it stops as well.
Advertisement
⚠️WarningSave your work first. If a process is writing to disk when it is cut off, you can lose that data permanently. Save your files, and stop any database or build job properly before you continue.

Why does ‘sudo shutdown’ not work in WSL?

The sudo shutdown command you may know from Linux does not do the job here. Ubuntu in WSL is a guest environment and has no permission to turn off the Windows host that runs it. The shutdown has to come from the Windows side, using the wsl command in PowerShell or Command Prompt.

How to manage WSL instances

Step 1Check what is running

Before you shut anything down, check what is running. Open PowerShell or Command Prompt and list your Linux environments. You don’t need administrator rights to do this. The list shows every distribution installed on the PC and whether each one is running or stopped. Write down the exact name of the distribution you care about, because you need it later if you want to stop only one.

It helps to know the difference between the two stop commands. wsl --shutdown stops WSL as a whole: every running distribution and the WSL virtual machine behind them. wsl --terminate stops one distribution by name and leaves the others running. Use the first when you want to free as much memory as possible or when WSL is stuck. Use the second when only one distribution is the problem.

💻Code
wsl -t Linux-machine-name

Replace “Linux-machine-name” with the name you noted in Step 1. The name must match the one in the list exactly. For Ubuntu it is often just Ubuntu, but a versioned install can have a longer name.

Once the command finishes, you can run the list command again to confirm the distribution now shows as stopped. To start Ubuntu again, open it from the Start menu or from Windows Terminal.

Troubleshooting common errors

A common error when working with Ubuntu in WSL is the message “System has not been booted with systemd.” It means systemd, the service manager Ubuntu normally uses, is not turned on for your install. The fix is a small change to the WSL configuration file.

  1. Open the configuration file in a text editor inside Ubuntu, as shown in the step above. Use sudo, because the file belongs to the system.
  2. Add the systemd setting under the section shown above, so the file contains the line below.
[boot] systemd=true
  1. Save the file and close the editor.
  2. Switch to PowerShell and run wsl --shutdown so WSL restarts and reads the new setting.
  3. Open Ubuntu again. systemd should now be running and the error should be gone.

If the error comes back, your WSL version may be too old to support systemd. Update WSL and try again. To undo the change, remove the line or set it to false, then shut WSL down again.

Automation and Scripting

If you shut WSL down often, a batch file saves typing. A batch file is a plain text file of commands that the Windows command interpreter runs when you open it. Placed on your desktop, it gives you a one-click shutdown.

  1. Open Notepad.
  2. Type the command wsl --shutdown on the first line.
  3. Click File Save as.
  4. Choose Desktop as the location.
  5. In Save as type, select All files. Otherwise Notepad adds .txt to the name and the file won’t run.
  6. Enter the file name stop-wsl.bat and click Save.

Double-click the new file to run it. A Command Prompt window flashes up and closes, and WSL is shut down. Remember that it stops every distribution without asking, so save your work first. To remove the shortcut, delete the file.

Summary

To sum up: use wsl --list --verbose to see which distributions are running, wsl --terminate to stop one distribution, and wsl --shutdown to halt all Linux services at once. Save your work before you run any of them, so nothing is lost while the background processes close.

“`

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Tags: #Windows 11

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *