X
Tech
Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.

Close

How to close apps in MacOS from the command line

If you run into an app on MacOS that refuses to close, there's a way to make it shut without having to reboot.
Written by Jack Wallen, Contributing Writer
The MacBook Pro on top of a table.
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 are 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.

1. Open the terminal app

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

2. Locate the name of the app to close

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:

ps aux |grep Mail

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

  • ps -- reports a snapshot of a current process
  • aux -- 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 command
  • grep -- print lines that match a pattern
  • Mail -- 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.

2. How to kill the application

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

killall Mail

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.

Editorial standards