How to kill a Mac App via the Command Line

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.





Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices.

He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

You can leave a comment on my original post.