Use taskkill for a Windows Service Stuck in Closing State

Windows | Published 2026-04-14 | By NetCollege Team

Summary: Step-by-step CMD guide to find a service PID, force-stop it with taskkill, and start the service again.

Introduction

When a Windows service is stuck in STOP_PENDING (often described as “closing”), a normal restart may fail.
A practical recovery pattern is:

  1. Find the service PID.
  2. Kill the process by PID.
  3. 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 example STOP_PENDING)
  • PID (for example 10776)

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 /f terminates 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 /?

Frequently asked questions

What does it mean when a service is stuck in closing or stopping state?

The Service Control Manager is waiting for the service process to exit, but the process does not shut down cleanly.

Is taskkill /f safe for services?

It is a force action and should be used for stuck services when normal stop/start fails; check application impact before running it in production.

How do I find the PID for a Windows service?

Use sc queryex ServiceName and read the PID line in the output.

← Back to category