How to kill a Mac App via the Command Line

- by

Sometimes it’s’ necessary for us to force-close an app on our Mac if it’s no longer responding to our commands. Usually we’d do that by pressing CMD+OPT+ESCAPE, which brings up a handy window from which we can choose a troublesome app.

Screen Shot 2016-08-23 at 16.10.14

But sometimes, this keyboard combination won’t work – for example, if we’re dealing with a remote Mac to which no physical keyboard is attached. In such cases, we can choose to force-close an app via the command line. Let me show you how to do that.

Connect to your Mac via SSH using a Terminal Session and find out what apps are currently running. We’ll so that with the top command:

top -u

Using the -u switch tells top to list the app with the highest CPU usage over time first. The command will display a list of running processes, much like this:

Screen Shot 2016-08-23 at 16.15.04

Take a look at the list and make a note of the troublesome app. In my case it’s Carrara, using 165% of my CPUs resources. By definition impossible, but let’s not worry about that. The important thing is this app’s PID (Process ID). Write it down or take a screenshot, we’ll need it in amount to kill the app (mine is 5964).

Press CTRL+C to stop top and return to the command line. Now issue the following command, replacing 5964 with your own PID:

kill -9 5964

And that’s it: the troublesome app has been force-closed and should vacate your system sharpishly. For more information on both top and kill, check out their respective man pages on your Mac.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

2 thoughts on “How to kill a Mac App via the Command Line”

  1. That’s a very good idea indeed, Khaled! The -9 option creates a “force kill” parameter. Without it, the application is asked to shut down normally. -9 is only a good idea if a regular shutdown does not work. Thanks for sharing!

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.