OS X: Schedule Launchctl to quit application at certain time I have created this launchctl .plist for opening an application at a specific time every day – or the next time the computer wakes from sleep.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;caffeine-timecontrol.job&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/Applications/Caffeine.app/Contents/MacOS/Caffeine&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;Minute&lt;/key&gt;&lt;integer&gt;40&lt;/integer&gt;
            &lt;key&gt;Hour&lt;/key&gt;&lt;integer&gt;7&lt;/integer&gt;
            &lt;key&gt;WeekDay&lt;/key&gt;&lt;integer&gt;1234567&lt;/integer&gt;
        &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


The above is supposed to wake app Caffeine at 7:40 AM Every day.

However, can I also include a clause to make the application terminate at 00:00 AM Every day if the computer is awake?

Meaning, is there an opposite to StartCalendarInterval, or would I have to go about it some other way, .e.g. via crontab?
One of these two methods should work, but I admit I have not tested them: 


Either you could write an AppleScript a la


tell application "Caffeine" to quit

put this in a file, then either launch the file from an osascript command or  put it into Script Editor and save it as an application and launch that as a an app


or you could use the good old killall command. You would have to lookup the name of process of the Caffeine process and send it a 

killall Caffeine


command, assuming that the process name of the Caffeine app is Caffeine (check  it from the Activity monitor or the ps command)