How to close apps in MacOS from the command line

June Wan/ZDNET

It’s a rare occasion that I find a MacOS app goes awry, but it does happen. When an app stops responding on the MacOS desktop, there’s a user-friendly GUI tool that can help you. Go to the Apple menu, click Force Quit, find the app in question, and Force Quit.

However, that trick doesn’t always work. On several occasions, I’ve discovered the Force Quit app refuses to do the job. When that happens, most people would probably turn to the restart option.

Also: How to optimize storage on your MacOS device

But don’t do that — there’s a better way. Because MacOS is very much grounded in Linux, you have the power of the command line at your fingertips. That power gives you the ultimate control over those apps, such that you can send them packing with impunity.

There’s two commands that I’m going to show you how to use. Once you have the hang of these two commands, you’ll never run into an app that you cannot close — no matter how stubborn it is.

Let’s get to it.

Locating the app name

What you’ll need: The only thing you’ll need for this task is a laptop or desktop running MacOS. It doesn’t matter which, nor does it matter which version of the OS you are using. I would, however, recommend you update MacOS to the latest version supported by your hardware and keep it up to date at all times. 

Also: How to update every Apple device

With that public service announcement out of the way, let’s get to the app-closing trick.

READ MORE  With 1 Heartbreaking Line, Flash Finally Faces a Problem 38 Years in the Making

The first thing to do is click the Launchpad icon in your dock, locate the icon for the Terminal app, and click it.

This is the tricky part. We have to find the name of the app we want to close. I often have issues with Apple Mail, so let’s use that app as our example. 

Also: How to quickly fix Apple Mail when it’s not working

Keep in mind that Linux commands are case-sensitive, so we’re not looking for mail, we’re looking for Mail. What we’re going to do is use two Linux commands, ps and grep, to list all instances of running apps that include the word Mail. The command for this task is:

For those who want to know, here’s the breakdown of the command:

ps — reports a snapshot of a current processaux — are ps options for all processes associated with a user ID, and use the default format for output| — this is the pipe that sends the output of the first command to the next commandgrep — print lines that match a patternMail — the pattern used for grep to match

The output of the command should include something like this:

jackwallen 20722 0.0 2.3 415470192 378896 ?? S Thur09PM 21:07.22 /System/Applications/Mail.app/Contents/MacOS/Mail

From that listing, we now know the app is, in fact, running under the name Mail. We can use that name to kill the application. The reason why we want to verify this name is to not only ensure we have the correct name, but to make sure we don’t accidentally kill an app we need running that might have a similar name.

READ MORE  The new WGA contract will change how Hollywood works

We’re now going to kill the Apple Mail application with the killall command, which is done with:

You should now find that Apple Mail has been forced closed, even when the Force Quit app failed to work.

A word of caution

Only use this process when you are certain the Force Quit app will not work and when you know the name of the app you want to kill. Don’t go randomly using the killall command on anything that’s running because you could cause problems with your OS or lose data. Use killall wisely and it will serve as a helping hand before you have to turn to rebooting.

Leave a Comment