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.
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:
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.