     @openPathOnEvent('application:open-your-stylesheet', 'atom://.atom/stylesheet')
     @openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md'))
 
+    app.on 'before-quit', =>
+      @quitting = true
+
     app.on 'will-quit', =>
       @killAllProcesses()
       @deleteSocketFile()

  atomProtocolHandler: null
  resourcePath: null
  version: null

  exit: (status) -> app.exit(status)


      if process.platform in ['win32', 'linux']
        app.quit()
        return
    @saveState() unless window.isSpec or @quitting

  # Public: Adds the {AtomWindow} to the global window list.
  addWindow: (window) ->
