How to Kill a Process Using Terminal on macOS
In this article
To kill a process on macOS, you use the Terminal app with commands like kill, pkill, or killall. The fastest method is to find the process ID (PID) with ps or pgrep, then run kill <PID>. This forcefully terminates an unresponsive app or background process without needing to restart your Mac.
What You'll Need
- Access to the Terminal app (found in /Applications/Utilities/).
- Administrator (admin) privileges if the process runs as root or belongs to another user.
- The name of the process or its PID (you can find these using the commands below).
Step-by-Step
- Open Terminal – Click the Launchpad icon in the Dock, type “Terminal”, and press Return. Or go to Finder > Applications > Utilities > Terminal.
- Identify the process – Run
ps aux | grep -i <name>(replace<name>with a keyword like “Safari” or “chrome”). This lists all processes with that keyword in their command line. Note the PID (the number in the second column). - Alternative: use pgrep – For a quick PID lookup, run
pgrep -i <name>. This prints only the PID(s) matching the name. - Kill by PID – Run
kill <PID>(e.g.,kill 1234). This sends a SIGTERM signal, asking the process to exit gracefully. - If it doesn't die, force kill – Run
kill -9 <PID>to send SIGKILL, which immediately terminates the process without cleanup. Use this only if the process is frozen or ignoring SIGTERM. - Kill by name (pkill) – Run
pkill -i <name>to kill all processes matching the name (case-insensitive). For example,pkill -i chromecloses all Chrome windows. - Kill all instances of an app (killall) – Run
killall <name>(e.g.,killall Safari). This kills every process with that exact name. Add-9for a force kill:killall -9 Safari. - Verify it's gone – Run
ps aux | grep -i <name>again. If nothing appears, the process is terminated.
Common Mistakes
- Killing the wrong process – Using a generic keyword like “java” or “python” can match many processes. Always check the full command line in
ps auxoutput before killing. - Using
kill -9too soon – Force-killing can leave temporary files or corrupt data. Try a normalkillfirst. - Forgetting the PID changes – PIDs are reused. If you restart an app, its PID changes. Always re-check before killing.
- Killing a system process – Some processes (like
kernel_task) are essential. Killing them can crash your Mac. Only kill processes you recognize. - Typing the name wrong –
killallis case-sensitive. Use the exact name as shown in Activity Monitor orps.
Tips
- Use
ps aux | sort -k 3 -rto list processes by CPU usage, helping you spot a runaway process. - If you're not sure what a process does, search for its name online before killing it.
- For apps that are stuck, try quitting normally first (Cmd+Q) or via the Dock menu. Terminal is a fallback.
- You can use
topto see live processes and their PIDs; pressqto quit. - To avoid typing long names, use Tab completion after typing part of the process name in
pkillorkillall.
Troubleshooting
“Operation not permitted” error – This usually means the process is owned by root or another user. Prepend sudo to the command (e.g., sudo kill 1234). You'll be prompted for your password. Be cautious: sudo grants full control.
Process still appears after kill – Some processes spawn child processes. Kill the parent process first, or use pkill -P <parentPID> to kill children. If it's a daemon (like a system service), it may restart automatically; check its configuration.
Terminal says “No such process” – The PID may have already exited. Run ps aux | grep <name> to see if it's still running under a different PID.
App freezes after kill – Force quit the app's remaining helper processes with killall -9 <appname> (e.g., killall -9 "Google Chrome Helper"). Then relaunch the app.
If the Mac becomes unresponsive – Hold the power button for 5 seconds to force shut down, then restart. This should be a last resort.
Frequently Asked Questions
What is the difference between kill, pkill, and killall?
kill sends a signal to a specific PID. pkill matches process names (or other attributes) and sends a signal to all matching PIDs. killall kills all processes with an exact name. Use kill when you know the PID, pkill for partial names, and killall for exact app names.
Is it safe to force kill with -9?
Force killing (SIGKILL) is safe for user apps that are frozen, but it doesn't let the app save data or clean up. It can cause file corruption in some cases. Always try a normal kill first.
Can I kill a process without knowing its PID?
Yes. Use pkill <name> or killall <name>. Both match by name, not PID.
What if the process is a system process I don't recognize?
Do not kill it. Search for the process name online or in Apple's support forums. Killing system processes can cause instability or data loss.
Why does the process come back after I kill it?
Some processes are managed by launchd (the system's service manager) and restart automatically. To stop them permanently, you'd need to unload the launch agent/daemon, which is beyond the scope of this guide. For user apps, they may relaunch if you have “Reopen windows when logging back in” enabled.
Can I kill a process from Activity Monitor instead?
Yes. Activity Monitor (in /Applications/Utilities/) shows all processes. Select one and click the X button to quit. This is often easier for beginners.