Windows – How to kill a task that is “lacking an instance”

killprocesstaskswindows 7

Spotify first killed itself but "something of it" kept lingering which was detectable as a task with PID 8664 and judging from the fact that RAM usage kept changing from time to time – it "did something".

Now first of all this process kept me from listening to music because Spotify refused to restart due to this instance hanging around.

So I tried to get rid of this process. But neither task manager nor the taskkill command (as Admin of course) succeeded in doing so.

taskkill at least gave me a "reason" which I will translate here.

>taskkill /pid 8664 /f
>taskkill /im spotify.exe /f

both gave:

ERROR: The process "spotify.exe" with PID 8664 could not be terminated.
Reason: There is currently no instance executed by this task.

I would like to know what that means and whether there is another option of how to terminate such a process.

(Windows 7 Pro 64 bit)

Best Answer

The process is almost certainly already dead, i.e. it is no longer executing any code. However, the bookkeeping about it doesn't go away until every handle to it and each of its threads is closed. You might have another program holding such a handle open (antivirus programs are a likely culprit), or it might have made a request before its death to a kernel-mode driver that is now hung (I once had a CD drive that caused this a lot). Further reading: "Why do some processes stay in Task Manager after they've been killed?" and "Why are there all these processes lingering near death, and what is keeping them alive?"

Spotify refuses to launch again because it sees a copy of itself already running, but it apparently just looks for another process called spotify. (A single-instance application is its own denial of service, in the words of Raymond Chen.) The easiest way to fix this would be to restart the computer, since that will wipe out all handles and bookkeeping.

But if you really feel like Fixing It YourselfTM, download Process Explorer, a fantastically useful free utility from Sysinternals. (I have no affiliation.) Run it, no installation required, and accept the EULA. Under File, choose Show Details for All Processes; this causes Process Explorer to relaunch as administrator. Then, under Find, choose Find Handle or DLL. Type the name of the zombie (well, corpse) process and press Search.

searching for handles

The Process and PID columns tell you what process owns the handle. The Type column indicates what sort of thing it is; we're interested in those of type Process or Thread. The Name column tells you what the handle is to. (A lot of processes own handles to themselves; these will go away if the owning application ends without problems in kernel mode.)

Danger: closing a handle that an application really needs is a great way to crash it. If possible, exit the application that owns the handle. But if you can't, or you just feel like hitting things with hammers...

Click an entry in that search window to open the handles pane. Right-click the newly highlighted entry in that pane and choose Close Handle to zap it out of existence.

Once all handles are closed, the process will vanish.

Related Question