Gracefully Close an Application from Command Line on Mac OS

Check tutorial of Gracefully Close an Application from the Command Line in Mac OS X

So after a lot of requests from our users here is a guide about Gracefully Close an Application from the Command Line in Mac OS X.

Closing apps cleanly is usually done through the appropriate application menu by choosing “Exit”, but the Mac GUI is clearly not accessible from the Mac OS X command line. So when most command line users are faced with the need to quit an application , wind up using the ‘kill’ command to end the process and forcibly exit the app, instead of performing a ‘soft’ kill. The obvious problem with terminating an app is that while the app is quitting, you may lose data in that process, and even session restore caches may not be sufficient to restore the data. So, where possible, it is usually best for users to close an application cleanly instead.

While not very well known, you can send a standard quit signal to any Mac OS X GUI app from the command line using the osascript command. It’s pretty easy to use, which is what we’ll cover here.

How to Cleanly close apps from the terminal in Mac OS X with osascript

Again, this will send a standard quit signal to an application instead of a kill (terminate) signal. This also means that the target application will not be forcibly closed if there is unsaved data without prompting the user for input (unless you have enabled the autosave setting for Mac OS X and the application does not prompt the user for it).

The basic syntax for sending a standard quit signal to a GUI application in Mac OS X from Terminal is as follows:

osascript -e ‘close app’ APPLICATIONNAME ”

For example, if you want to close Calendar from the command line, replace APPLICATIONNAME with ‘Calendar’

osascript -e ‘Close’ app ‘Calendar’

Since Calendar syncs and has no save option, you won’t see the standard save dialog when you try to close the app. For apps that do have save options, and when Mac OS X has auto-save turned off, the save dialog opens as usual.

Another benefit of using osascript to properly exit apps is that you can provide an actual application name, which is much easier to remember and a lot more user-friendly than relying entirely on process ID numbers included with the kill command to hear. Note that modern versions of Mac OS X provide an improved kill command that is more user-friendly known as pkill.

You can use this in a bash script to quit applications from the command line, or you can even tweak it to behave the same way as “Quit All Open Apps” with Automator trick we mated a while back.

Gracefully Close an Application from the Command Line in Mac OS X Guide is free?

Starting from: Free
This guide is a free model
Free Trial: May be included, please check on the official site, we mentioned above.
The Gracefully Close an Application from the Command Line in Mac OS X tutorial price is Free or Freemium. This means you can truly enjoy the Gracefully Close an Application from the Command Line in Mac OS X guide.

The Gracefully Close an Application from the Command Line in Mac OS X guide gives you an easy-to-use and efficient management and Gracefully Close an Application from the Command Line in Mac OS X allows you to focus on the most important things. It’s friendly guide to use maybe you will love it and Gracefully Close an Application from the Command Line in Mac OS X tutorial can be used on Linux, Windows or android devices.

Gracefully Close an Application from the Command Line in Mac OS X: benefits

  • The Gracefully Close an Application from the Command Line in Mac OS X tutorial is free .
  • Helps many users follow up with interest in a timely manner.
  • The price of the Gracefully Close an Application from the Command Line in Mac OS X guide is free.

Gracefully Close an Application from the Command Line in Mac OS X: FAQ

Tutorial Summary: Gracefully Close an Application from the Command Line in Mac OS X

In this guide, we told you about Gracefully Close an Application from the Command Line in Mac OS X; please read all steps so that you understand Gracefully Close an Application from the Command Line in Mac OS X in case if you need any assistance from us, then contact us.

How this tutorial helping you?

So in this guide, we discuss the Gracefully Close an Application from the Command Line in Mac OS X, which undoubtedly helps you.

What is actual time in which this method complete?

The time to complete the Gracefully Close an Application from the Command Line in Mac OS X tutorial is 10+ minutes.

What are the supported Device?

Apple

What are the supported Operating system?

mac OS


Gracefully Close an Application from the Command Line in Mac OS X Tutorial: final note

For our visitors: If you have any queries regards the Gracefully Close an Application from the Command Line in Mac OS X, then please ask us through the comment section below or directly contact us.
Education: This guide or tutorial is just for educational purposes.
Misinformation: If you want to correct any misinformation about the guide “Gracefully Close an Application from the Command Line in Mac OS X”, then kindly contact us.
Want to add an alternate method: If anyone wants to add the more methods to the guide Gracefully Close an Application from the Command Line in Mac OS X, then kindly contact us.
Our Contact: Kindly use our contact page regards any help. You may also use our social and accounts by following the Whatsapp, Facebook, and Twitter for your questions. We always love to help you. We answer your questions within 24-48 hours (Weekend off).
Channel: If you want the latest software updates and discussion about any software in your pocket, then here is our Telegram channel.

Compsmag
Logo