By Alvin Alexander. Last updated: November 28, 2023
If you ever need to close a MacOS application (gracefully) from the Mac Terminal command line or from a shell script, I can confirm that this command works:
osascript -e 'quit app "Safari"'
I use that command from a Mac/Unix shell script to close the Safari browser in an automation script I’m writing, and it works fine. Just replace Safari
in that command with the name of the application you want to close.