If you are an IT support administrator, sometimes you may come across a situation where the Windows service process hangs at “Stopping” or “Not Responding“. They would then need to kill the Windows that hangs on stopping.
This situation occurs when you try to stop a service, but it does not allow you to. Also, the control buttons for the service are frozen and hence, you are not allowed to stop the service from the Service control manager/services.msc. While you can restart your Windows 10 PC and check if it resolves the issue, it may not work most of the times. Instead of rebooting the server, you can try killing the Windows service that hangs on stopping. Let’s see how.
Method 1: Using Taskkill in Command Prompt
Find out the service name
Step 1: Right-click on Start and select Run to launch the Run command window.
Step 2: In the Run command window, type services.msc and hit Enter to open the Service manager.
Step 3: In the Services window, look for the service which has hung.
Make a note of the Service name.
*Note – For instance, we are facing an issue with the Realtek audio and so we double-clicked on Realtek Audio Service.
Next, in the Realtek Audio Service dialogue box, we noted the Service name, which is RtkAudioService.
Find out the service PID and Kill the PID
Step 1: Press the Win + R shortcut keys to open the Run command window.
Step 2: In the search field, type cmd and press the Ctrl + Shift + Enter keys together to open Command Prompt in admin mode.
Step 3: Copy and paste the below command in the Command Prompt (admin) window:
sc queryex servicename
*Note – Replace the highlighted part with the service named you noted above.
Step 4: Make note of the PID of the service.
Step 5: Now, in the same elevated Command Prompt window, run the below command and hit Enter:
taskkill /f /pid PID
*Note – Replace the highlighted part with the PID you copied in the Step 4.
Step 6: On successful completion of the process you will receive the below message:
The process with PID XXXX has been terminated
*Note – Make sure you kill the right process and not a critical Windows service which may force your PC to restart automatically.
Method 2: By Stopping Windows Services using PowerShell
Windows PowerShell is another option using which you can force stop the service. Here’s how:
Step 1: Right-click on the Start menu and select Windows PowerShell (Admin).
Step 3: Copy and paste the below command in the Windows PowerShell (admin) and hit Enter to get a list of services in the stopping condition:
Get-WmiObject -Class win32_service | Where-Object {$_.state -eq 'stop pending'}
Step 4: Now, you can terminate the processes of all the detected services using Stop-Process cmdlet.
You can create a loop by adding both the operations and get a command that automatically kills all the stuck service processes.
Method 3: By Looking for the Hang Process in Resource Monitor
Resource Monitor is another app that can help you find the process that caused the process to hang. Let’s see how:
Step 1: Right-click on Start and select Run.
Step 2: This will open the Run command box.
Here, type Resmon in the search field and hit Enter to open the Resource Monitor app.
Step 3: Select the CPU tab and look for the stuck process.
Right-click on the process and select Analyze Wait Chain.
Step 4: In the Analyze Wait Chain window, you will see that your selected process is waiting for another process.
Select the process thread/s and click on the End process button below.
*Note – You don’t need to kill it, if you are waiting for svchost.exe or another process.
You can also analyze the wait chain for this process.
Look for the PID of the process that the svchost.exe file is waiting for and terminate it.
Method 4: By Killing a Hung Process using Process Explorer
Even if you are the local administrator, you may not have permissions for some processes and as a result, you may not be able to kill some processes that are aligned with the SYSTEM. Therefore, in order to terminate such processes, you must grant enough permissions to the local Administrators. For this, you would the assistance of two utilities – psexec.exe and ProcessExplorer.
Step 1: Visit the below link (Microsoft’s official download page) to download the Process Explorer app.
https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer
Step 2: Open the Zip folder and drag the procexp.exe file to the desktop.
Step 3: Now, right-click on it and select Run as administrator.
Step 4: When in the Process Explorer window, go to the left side of the window and under Process, select the process that’s hung on stopping.
Right-click on it and select Properties.
Step 5: In the Properties dialogue box, select the Services tab and click on Permissions.
Step 6: Now, in the Permissions dialogue box, under the Security section, go to the Group or user names field and select Administrators.
Next, go to the Permissions for Administrators field and check the Allow box next to Full Control.
Press OK to save the changes.
Step 7: Press OK again the Properties window to apply the changes and exit.
Now, try and kill the windows service that hangs on Stopping.
Many users have also reported, sometimes simply rebooting your system can help fix the issue. If the issue persists, contact the Microsoft Support and schedule it for some odd hour and it should fix the issue sometimes.