Force-stopping WSL when it gets stuck (with taskkill)
Sometimes WSL or Docker Desktop on Windows gets stuck. CPU usage spikes, RAM usage keeps growing, and commands like wsl --shutdown don’t seem to help.
In those situations I use a simple Windows command that force-kills the WSL service.
taskkill /f /im wslservice.exe
What it does
taskkill- Windows command used to terminate processes./f- Forces the process to terminate./im wslservice.exe- Targets the WSL service process that manages the WSL virtual machine.
When this process is killed, Windows stops the underlying WSL VM and all running distributions.
When this is useful
This can help when:
- WSL becomes unresponsive
- Docker containers hang and won’t stop
- RAM or CPU usage keeps growing
wsl --shutdowndoes nothing- the WSL VM refuses to terminate
After running the command, the next time you open WSL it will start a fresh VM instance.
Use with caution
This is a hard stop, not a graceful shutdown.
It will immediately terminate:
- all running WSL distributions
- any processes inside them
- running Docker containers using the WSL backend
Possible side effects:
- unsaved work inside WSL will be lost
- file operations may be interrupted
- databases or services running inside WSL may not shut down cleanly
Because of that, it should be used only when normal shutdown methods fail.
Tip
Before force-killing WSL, try the normal shutdown command first:
wsl --shutdown
If that doesn’t work, taskkill /f /im wslservice.exe is usually the quickest way to recover a stuck WSL environment without rebooting Windows.