Can't quit app launched through launchd As it says in the title, "Can't quit app launched through launchd"—or more precisely, I can quit it, but it then automatically restarts again.



Background: I prefer to use BusyCal, not iCal, but there are some calendar-ish things that have to be done by iCal before BusyCal can get the results. I figured I'd create two launchd scripts: one to launch iCal every day at 5 am, and another to quit it a few minutes later.



Here's the plist to launch (in ~/Library/LaunchAgents/com.dori.iCalLaunch.plist):

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//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;KeepAlive&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.dori.iCalLaunch&lt;/string&gt;
    &lt;key&gt;OnDemand&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/Applications/iCal.app/Contents/MacOS/iCal&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;ServiceDescription&lt;/key&gt;
    &lt;string&gt;iCal Launcher&lt;/string&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Hour&lt;/key&gt;
        &lt;integer&gt;5&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


My understanding was that I didn't need the KeepAlive and OnDemand keys, but I put them in anyway to try to stop the relaunching. 

Here's the plist to quit (in ~/Library/LaunchAgents/com.dori.iCalQuit.plist):

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//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;com.dori.iCalQuit&lt;/string&gt;
    &lt;key&gt;Program&lt;/key&gt;
    &lt;string&gt;/usr/bin/osascript&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;osascript&lt;/string&gt;
        &lt;string&gt;-e&lt;/string&gt;
        &lt;string&gt;tell application "iCal" to quit&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;ServiceDescription&lt;/key&gt;
    &lt;string&gt;iCal Quitter&lt;/string&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Hour&lt;/key&gt;
        &lt;integer&gt;5&lt;/integer&gt;
        &lt;key&gt;Minute&lt;/key&gt;
        &lt;integer&gt;10&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Based on my log files, they both run just fine—but after the Quit runs, iCal relaunches.

Any ideas for things to try, or things that might be causing this?
If you don't specify &lt;Minute&gt; in the &lt;StartCalendarInterval&gt;, then (just like cron's *) it will run the job every minute.