In a regular Cocoa application you can handle application start/stop with the AppDelegate's DidFinishLaunching and WillTerminate methods.
But it only works if the application has a main window.
I'm developing an agent, which does not have any UI, and I log the events with NSLog().
In addition, I only call NSApplication.Init(), as NSApplication.Main() would write some errors to the Mac OS X Console.
Is there a way to handle when the user clicks 'Quit' for an agent in the Activity Monitor?