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"'

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.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!