title: How can I tell my Cocoa application to quit from within the application itself?
body: <p>I'm looking for a good way to tell my Cocoa application to quit itself. Rest assured that this will not be used for production code. I'm just looking for an easy way to run one test and then close the application during debugging.</p>
  
  <p>I have found that <code>exit(0);</code> will close the app, but it bypasses all of the normal application exit procedures, and I would like to keep all of them in place.</p>
  
  <p>Essentially I want things to work as if a user pulled "Quit" from the menu, but I want it to happen automatically after I have finished with my test.</p>
  
  <p>My code currently looks like this:</p>
  
  <pre><code>#if (SUPERFANCY_TESTING_MODE)
      [self doSomething];
      exit(0); // &lt;-- I need something better to go here
  #endif
  </code></pre>