In short, you either call exit(3) , or completely bypass Cocoa's standard reset mechanisms, or you cannot set the exit code (without going through the hoops as you describe).
As Jason mentioned, there is nothing important for the system that occurs during the failure of the application. On the other hand, your application may have something critical, but this is solely due to the implementation of your application (and not the default in Cocoa).
But, in fact, do not do this - the user likes to forcibly leave the grudge, and your application should be designed so that in the end it is not catastrophically catastrophic.
source share