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:

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:

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.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs several YouTube channels and websites, and he's also live on Twitch sometimes. To support him on his mission to make the world a better place, you can support him on Patreon or buy him a coffee.

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 Reply to Khaled Annajar Cancel reply