Introduction
When a Windows service is stuck in STOP_PENDING (often described as “closing”), a normal restart may fail.
A practical recovery pattern is:
- Find the service PID.
- Kill the process by PID.
- Start the service again.
Run all commands in an elevated Command Prompt.
Step 1: Find service name in Services
Open services.msc, locate the service, and note its service name (not just display name).
Example service name:
VeeamManagementAgentSvc
Step 2: Find PID of the service
sc queryex VeeamManagementAgentSvc
Look for:
STATE(for exampleSTOP_PENDING)PID(for example10776)
Step 3: Force-stop the stuck process
taskkill /f /pid 10776
Step 4: Start the service again
net start VeeamManagementAgentSvc
Full example flow (Veeam service)
sc queryex VeeamManagementAgentSvc
taskkill /f /pid 10776
net start VeeamManagementAgentSvc
Reusable variable pattern (CMD)
set sn=wuauserv
sc queryex %sn%
Then kill the PID returned by sc queryex:
taskkill /f /pid 8772
Optionally start it again:
net start %sn%
Quick checks after recovery
- Re-run
sc queryex <ServiceName>and confirm the PID/state changed as expected. - Check Event Viewer for service errors around the same timestamp.
- Confirm dependent applications are healthy.
Notes
taskkill /fterminates the process immediately.- If the service keeps getting stuck, investigate underlying causes (hung threads, dependency failures, AV interference, or resource pressure).
- For full syntax, use:
sc queryex /?
taskkill /?
net start /?