How to Schedule an Application to Quit

Applications can be scheduled to launch using Power Manager's built-in Schedule Assistant, but what if you need to schedule an application to quit? In this recipe we will walk through how to ask an application to quit.

Applications can be scheduled to launch using Power Manager’s built-in Schedule Assistant, but what if you need to schedule an application to quit? In this recipe we will walk through how to ask an application to quit.

There are a handful of ways to quit a running application in Mac OS X. The recommended way is to use AppleScript to ask the application to quit. This is the most polite method because it gives the application the greatest opportunity to clean up before quitting.

The AppleScript needed to quit TextEdit is:

tell application "TextEdit"
    quit
end tell

You can change the tell application line to match the application you wish to quit. To quit the presentation application Keynote, the following variant would be used:

tell application "Keynote"
    quit
end tell

Well behaved Mac applications will respond to a quit request sent via an AppleScript. Poorly behaving applications, or processes not specifically designed for the Mac, can be quit using a UNIX method involving sending a signal. This method is not covered in this recipe.

Let’s look at how to schedule the application PowerPoint to quit at a specific time each day.

Create a Scheduled Quit Event

  1. Launch Power Manager.

  2. Click on the Add… button to create a new event.

Click Add… to begin creating the quit application event

Click Add… to begin creating the quit application event.

  1. Select the Run a script daily task within the Schedule Assistant.

Use the Run Script Daily task in the Schedule Assistant.

Use the Run Script Daily task in the Schedule Assistant.

  1. Click Continue to move to the Script step.

  2. Copy and paste the following AppleScript into the Script step:

#!/usr/bin/osascript

tell application "Microsoft PowerPoint"
	quit
end tell

Paste in the quit AppleScript in the Script step.

Paste in the quit AppleScript in the Script step.

  1. Click Continue to move to the When step. On the When step adjust the time of day and days to trigger the quit event.

Set the time and days of the week to trigger the quit application event.

Set the time and days of the week to trigger the quit application event.

  1. Click Continue through until the Why step. On the Why step provide a name and any notes you desire for the event, then click Continue to move to the Confirm step.

Continued passed the Constraints step for this event.

Continued passed the Constraints step for this event.

Provide a name and any notes about the purpose of the event.

Provide a name and any notes about the purpose of the event.

  1. Click Add to create the new quit application event.

Confirm the event should be created and immediately scheduled.

Confirm the event should be created and immediately scheduled.

The quit application event is ready and scheduled immediately.

The quit application event is ready and scheduled immediately.

The quit application will be scheduled immediately. There is nothing more to do but wait for the trigger time to arrive. Power Manager will automatically wake your Mac if it is sleeping when the trigger time is due.