How can I write a launchd service that will actually stop the service? So I have a plist to keep monit running:

&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.monit.service&lt;/string&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/local/Cellar/monit/5.10/bin/monit&lt;/string&gt;
        &lt;string&gt;-d 60&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/var/log/monit.log&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;


I can do launchctl load /Library/LaunchDaemons/com.monit.service.plist to start the service, but launchctl unload /Library/LaunchDaemons/com.monit.service.plist will not stop it. I can see that the process keeps running no matter what I do.

The process shows up like this(note how the binary path doesn't show up, only the last argument):

output of ps aux:

root            14656   0.0  0.0  2482248   1656   ??  S     6:55PM   0:00.09 -d 60


How can I write the launchd plist so that it will actually stop the freaking process whenever I want it to stop?
Get rid of the -d 60 arguments and use the launchd key StartInterval instead. Also make sure the process does not daemonize itself. According to the monit man page this is accomplished by using the -I option.