Command Prompt: How to Close a Program That Won't Quit
In this article
You can close a stuck program from Command Prompt in Windows by finding its process name and then terminating it with the taskkill command. The shortest working version is: open Command Prompt, run tasklist to find the program's image name, then run taskkill /IM program.exe /F (or taskkill /PID 1234 /F using the process ID). This forces the program to end even when the normal close button, Alt+F4, or Task Manager's End Task button does not respond. It is useful when a window is frozen, invisible, or refusing to shut down, and it works on Windows 10 and Windows 11. Menu labels and command output can differ slightly by Windows version, edition and region, but the commands below are the standard ones shipped with Windows.
What You'll Need
- A Windows PC (Windows 10 or Windows 11; the commands also work on older supported versions).
- Access to Command Prompt. You do not need administrator rights for programs you started yourself, but you do need an administrator Command Prompt to end processes owned by another user or by the system.
- The name of the program you want to close, or the ability to recognise it in a process list.
- Unsaved work in that program will be lost when you force it to close, so save anything you can reach first.
Step-by-Step
- Save what you can. Forcing a process to end discards unsaved changes in that program. If the program still responds at all, try saving your document first, then close it normally.
- Open Command Prompt. Press the Windows key, type
cmd, and press Enter. Alternatively, press Windows+R, typecmd, and press Enter. If you need to close a program running under another account or a system process, right-click Command Prompt in the Start menu search results and choose Run as administrator. A User Account Control prompt will appear; approve it. - List the running processes. Type
tasklistand press Enter. You will see columns for Image Name, PID (process ID), Session Name, Session#, and Mem Usage. Scroll through the list, or typetasklist | moreto page through it one screen at a time. If you already know roughly what you are looking for,tasklist /FI "IMAGENAME eq program.exe"filters the list to that name. - Identify the right process. The Image Name is the executable file name, such as
notepad.exe,chrome.exeorwinword.exe. The PID is the number in the second column. If several entries share the same image name (browsers often run many processes), note the PID of the one you want, or accept that closing by image name ends all of them. If you are unsure which window belongs to which process, switch to the program, open Task Manager with Ctrl+Shift+Esc, and match the name there. - Close it by image name. Type
taskkill /IM program.exeand press Enter, replacingprogram.exewith the exact image name from the list. This sends a polite close request, similar to clicking the X. If the program is frozen, this request may be ignored. - Force it if the polite request fails. Type
taskkill /IM program.exe /Fand press Enter. The/Fswitch forces termination. Windows should respond with a success message such as "SUCCESS: The process ... has been terminated." - Or close by PID instead. If you want to end one specific instance, type
taskkill /PID 1234 /F, replacing 1234 with the PID you noted. This is the safer choice when several processes share a name. - Close child processes too. Some programs launch helper processes. Add
/Tto end the process and everything it started, for exampletaskkill /PID 1234 /T /F. This is common with installers and launchers that leave background helpers running. - Verify it is gone. Run
tasklistagain, or repeat the filtered version, and confirm the image name no longer appears. If it is still listed, the process may be protected, owned by another user, or restarting itself through a service. - Close Command Prompt. Type
exitand press Enter, or click the X on the window. Nothing else is changed by these commands; they only end the process you targeted.
Common Mistakes
- Using the wrong name. The image name is the executable name, not the window title. "Microsoft Word" is
winword.exe, and the display name in the Start menu will not work intaskkill. - Forgetting the
.exe.taskkill /IM chromeusually fails; usechrome.exe. - Killing all instances by accident. Closing by image name ends every process with that name, including browser tabs and background helpers. Use the PID when you only want one.
- Skipping the save attempt.
/Fdoes not prompt and does not save. Any unsaved document, draft or edit is lost. - Running without administrator rights and expecting it to work on system processes. A standard Command Prompt cannot end processes owned by another user or by Windows itself. You will get "Access is denied" instead.
- Typing the command into the wrong window. The commands must go into Command Prompt, not into the Run dialog or a program's search box.
Tips
- Add
/?after a command, as intaskkill /?, to see the full list of switches and their exact wording on your Windows version. - Use
tasklist /FI "STATUS eq NOT RESPONDING"to show only processes Windows has flagged as not responding, which is often exactly the frozen program you are hunting. - Quote image names that contain spaces, for example
taskkill /IM "my program.exe" /F. - If you plan to end a program regularly, note its image name once and reuse it. The PID changes every time the program starts.
- Prefer the polite command first and
/Fsecond. Forcing a program mid-write can occasionally leave a temporary or lock file behind, which a normal close avoids. - Task Manager's End Task does the same job with a mouse. Command Prompt is handy when Task Manager itself is slow, hidden, or when you want to script the close.
Troubleshooting
- "Access is denied." The process belongs to another user or to Windows. Close Command Prompt, reopen it with Run as administrator, and try again. If it still fails, the process may be protected and should be left alone.
- "ERROR: The process ... not found." The name is misspelled, the program already closed, or you are looking at a different user's process list. Run
tasklistagain and copy the image name exactly. - The process disappears and comes straight back. A service or scheduled task is restarting it. Closing it repeatedly will not help; check the program's own settings or Windows Services for an automatic restart, or restart the PC.
- The whole desktop or Start menu is unresponsive. Restarting Windows Explorer can help, but it closes your taskbar and open File Explorer windows temporarily. Signing out and back in, or restarting the PC, is the safer general fix.
- You closed the wrong thing. Reopen the program from the Start menu. Unsaved data in the closed program cannot be recovered by these commands; check the program's own recovery or autosave feature if it has one.
- Commands are not recognised. Confirm you are in Command Prompt and not PowerShell, where some syntax differs, and check for typos in the command name.
Frequently Asked Questions
Does taskkill close a program the same way as clicking the X?
Without /F, it sends a normal close request, which the program can handle by prompting to save. With /F, it terminates the process immediately and unsaved changes are lost.
Can I close a program I cannot see on screen?
Yes. If it appears in tasklist, it can be closed by image name or PID even when its window is hidden or off-screen.
Why does closing by image name end several processes?
Many programs, especially browsers, run one main process plus helper processes that share the same executable name. taskkill /IM targets all of them; use /PID to target one.
Do I need administrator rights?
Only for processes owned by another user or by Windows. Programs you started yourself can usually be closed from a standard Command Prompt.
Will this damage the program or my files?
The program itself is not damaged. The main risk is losing unsaved work in that program, so save first whenever possible.
Can I use these commands on a Mac?
No. taskkill and tasklist are Windows commands. On macOS, use Activity Monitor or the kill command in Terminal instead.