How to Quit Applications on Mac Using Terminal


If you want to quit an application that running as a UI on your Mac via the Terminal you can make use of osascript. This command will terminate the applications gracefully.

Example 1:

Say you have a Google Chrome application running and you want to quit it via terminal.

osascript -e 'quit application "Chrome"'
Gracefully quit Google Chrome App using Terminal

Example 2:

You want to gracefully quit Android Studio app that's running gracefullyl.

osascript -e 'quit application "Chrome"'


How to Quit Application by Force via Terminal

If an application is not responding, then you can make use of the kill command.

For this first you need to run the ps command to find the process id - PID

ps -ef | grep 'Android Studio'        
  501  6958     1   0 12:36AM ??         0:14.38 /Applications/Android Studio.app/Contents/MacOS/studio
  501  6960  6958   0 12:36AM ??         0:00.01 /Applications/Android Studio.app/Contents/bin/fsnotifier
  501  6972  6682   0 12:37AM ttys000    0:00.00 grep Android Studio
kill -9 6958 

Note: kill -9 will force kill the application.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap