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.
Facing issues? Have Questions? Post them here! I am happy to answer!
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
- How to show line numbers in Nano on Mac
- How to install Jupyter Notebook on macOS Sonoma
- How to Disable Remote Management using Mac Terminal
- Test internet speed using macOS Terminal command
- Docker Desktop needs privileged access macOS
- Google Search Hot Trends Screensaver for Mac OS X
- How to do calculations in Mac Terminal
- How to make TextEdit the default text Editor on Mac
- How to Show Full Website Address on Safari for Mac (Ventura/Sonoma)
- The Zsh Shell - Mac Tutorial
- Opening mac Terminal
- How to change the name of your Mac running on macOS Ventura 13
- How to find the Battery Cycle Count on macOS Ventura
- How to set an emoji as Zsh terminal prompt in macOS
- How to access Trash Folder using Mac Terminal Command
- macOS Ventura XCode Command Line Tools Installation
- Hide Bluetooth icon on Mac Menu Bar macOS Ventura 13
- How to run .sh file in Mac Terminal
- Terminal Command to get the list of available shells in macOS
- How to see Storage Information on macOS Ventura
- How to Go To /usr/local/bin on Mac Terminal?
- How to do screen recording on Mac
- How to Find File and Directory Size in Mac Terminal
- Open .bash_profile File in TextEdit using Terminal
- Remove Now Playing icon from macOS Big Sur Menu Bar
- Java code to check Internet Connection on Android Device Programmatically - Android
- How to Open Trash on Mac - MacOS
- How to create a SharePoint list from an existing list with same columns, views, formatting, data - SharePoint
- Install RabbitMQ on Docker - Docker
- Cannot access Windows application shortcuts on Start menu and Taskbar - Windows
- Install Homebrew (brew) on Mac M2 - MacOS
- Clear browsing history in Safari on Mac Ventura 13 - MacOS
- WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. - PIP