Posted on May 13, 2016 · Posted in Windows Server 2012

Killing Windows Services that Hang on “Stopping”

Most Windows administrators have faced a problem, when they try to stop (restart) a service, but it gets stuck with the Stopping status. You won’t be able to stop this service from Service Management (services.msc) console, since all buttons for this service become inactive. The easiest way is to restart Windows, but it is not always acceptable. Let’s consider an alternative way, which allows to kill stuck Windows service or process without system restart.

Windows Service hang on "Stopping"

If in 30 seconds after an attempt to stop the service, it doesn’t stop, Windows displays this message:

Windows Could not stop the xxxxxx service on Local Computer
Error 1053: The service did not respond in a timely fashion

The easiest way to shut down a stuck service is to use taskkill. First of all, find the PID (process identifier) of the service. As an example, let’s take Windows Update, its system name is wuauserv (you can check the name in the service properties in services.msc console).

Important. Be attentive. A forced shutdown of critical Windows services can result in BSOD or system restart.

Run this command in the command prompt with the administrator privileges (It is important, or access denied error will appear):
sc queryex wuauserv
In our case the PID is 816.
To force shutdown of the process with the PID 816:

taskkill /PID 816 /F

kill service process by pid

SUCCESS: The process with PID 816 has been terminated.

This command forces the service shutdown.

TASKKILL /F /FI «SERVICES eq wuauserv»

Or kill all hang services

taskkill /F /FI «status eq not responding»

Later you can get back to the Service Management console and start the service manually.

You can force a service to shut down in a more elegant way, without manual search of the PID. PowerShell will help us to do it.

Using the following command, you can obtain the list of services with the Stopping status:

Get-WmiObject -Class win32_service | Where-Object {$_.state -eq 'stop pending'}

list of services with "Stop pending" status

The Stop-Process cmdlet allows to shut down the processes of all found services. Having united both operations into a cycle, we get a script to automatically shut down all processes of the stuck services in the system:

$Services = Get-WmiObject -Class win32_service -Filter "state = 'stop pending'"
if ($Services) {
foreach ($service in $Services) {
try {
Stop-Process -Id $service.processid -Force -PassThru -ErrorAction Stop
catch {
Write-Warning -Message " Error. Error details: $_.Exception.Message"
else {
Write-Output "No services with 'Stopping'.status"

Powershell Stop Process


Related Articles