5

In past versions of Windows 10, WSL could be exited by closing all active terminals but with the introduction of background tasks in WSL this no longer works. Is there a way to exit WSL without rebooting the host system?

  • Stop the background task from wsl. – Biswapriyo May 3 '18 at 17:27
  • Background task create a process with wslhost.exe executable. One may kill that process but the result will be catastrophic. – Biswapriyo May 3 '18 at 17:30
  • I suppose setting up an alias to kill all background tasks and exit would work, it just feels like far too much of a hack. But if that's what it takes, that's what I'll do – laverya May 3 '18 at 18:30
11

Yes, it is.

As an Administrator restart the windows Service "LxssManager" on Windows 10. This does a clean boot of the WSL. The services in the Linux Subsystem - for example xrdp - must be restarted if not enabled for autostart.

|improve this answer|||||
10
  1. WIN+R -> services.msc
  2. Find LxssManager

    enter image description here

  3. Right-click -> Restart

    enter image description here

|improve this answer|||||
3

A Powershell solution

Get-Service LxssManager | Restart-Service
|improve this answer|||||
  • The most elegan solution in my opinion. Don't forget that you have to start the PowerShell with administrator privilege tough. – kruemi Dec 14 '19 at 10:45
-1

As the other answers mention, specifically for windows 1803, the following should work from powershell or cmd:

net stop LxssManager

As highlighted by @Ramhound, only for newer versions, which have wsl 2, you can also run this from powershell or cmd:

shutdown all instances:

wsl.exe --shutdown 

shutdown a specific instance (e.g. Ubuntu):

wsl.exe -t Ubuntu 

to show the current list of instances:

wsl.exe -l
|improve this answer|||||
  • To my knowledge wsl.exe does not exist on Windows 10 version 1803 – Ramhound 2 days ago
  • Voting is anonymous – Ramhound yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.