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!
- How to list all users in Mac Terminal
- Docker Desktop needs privileged access macOS
- Mac: How to show count of files and folders in Finder
- How to Change Background Color TextEdit on Mac
- How to adjust MacBook Desktop icons size
- Test internet speed using macOS Terminal command
- How to change the default font and text size in Microsoft Excel for Mac
- How to install Java on macOS [Big Sur]
- How to come out of dquote prompt in Terminal - macOS/Linux
- How to Increase MacBook Trackpad Cursor Speed on macOS Ventura/Sonoma
- Fix: Microsoft Excel Quit Unexpectedly on Mac
- How to Adjust macOS System Font Size
- How to Quit Applications on Mac Using Terminal
- How to check zsh installed version using terminal
- Two Ways to Extract rar (*.rar) files on Mac
- How to Right Click on Mac Desktop?
- How to Add Brew to PATH M1/M2 Mac
- How to search (find) in macOS Terminal Console Text
- macOS 13 Ventura - The New About this Mac Window
- TextEdit Get the count of lines in a file
- How to run .sh file in Mac Terminal
- Google Search Hot Trends Screensaver for Mac OS X
- Check Reboot History Mac
- [Solution] Mac Update Stuck Preparing macOS Ventura 13.0 About 30 minutes remaining
- Display Safari URL address link on hover
- Emoji Checkbox with Happy (On) and Sad (Off) Face - CSS
- JSON column formatting to preview SharePoint Online file on mouse hover - SharePoint
- Python 3.x - SQLite 3 Database CRUD Operations Examples - Python
- Android Studio emulator/Device logCat logs not displayed - Android-Studio
- ls Command to See Hidden Files - Linux
- Word-wrap Eclipse Console logs - Eclipse
- Add Custom header and footer to Windows Notepad file - NotepadPlusPlus
- The Zsh Shell - Mac Tutorial - MacOS