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.
Have Questions? Post them here!
- How to find path of file on Mac Terminal
- How to disable Siri on Mac Monterey
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Select Line Number TextEdit on Mac
- Go to Specific file path using Mac Finder
- How to find Java HOME in Mac Terminal
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Must Know Homebrew Commands for Mac/Linux Users
- How to Insert an Inverted Question Mark on Mac ¿
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- How to make macOS Terminal window Transparent (or Opaque)
- How to check of Updates on Microsoft Edge Browser on Mac (macOS)
- Limit scrollback rows in macOS Terminal
- How to identify installed Java (JDK) Version on macOS
- Keyboard Shortcut to delete a file on a Mac [Macbook]
- Open Docker from Terminal Command on Mac
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023]
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- How to remove username from Mac Menu Bar?
- macOS Ventura XCode Command Line Tools Installation
- Where is .zshrc file located in macOS
- How to Show Path of Files or App in Mac Spotlight Search
- How to enable root user on Mac Terminal
- Install Java 17 (LTS) JDK on ARM based M1/M2 Mac Natively
- Fix Apache Tomca: java.lang.OutOfMemoryError: PermGen spaceError - Tomcat
- How to word wrap in HTML - Html
- Complete Reference of ArrayList Collection in Java with Examples - Java
- [Java] How to throws Exception using Functional Interface and Lambda code - Java
- [Solution] IDEA IntelliJ System.out.println function shortcut (sysout alternative for eclipse IDE) - HowTos
- Java JDBC Batch Update Example with PreparedStatement - Java
- How to kill tomcat server process using Mac Terminal Command - Tomcat
- How to create a New Project in Visual Studio Code (VS Code) - HowTos