       if process.platform in ['win32', 'linux']
         app.quit()
         return
-    @saveState() unless window.isSpec
+    @saveState() unless window.isSpec or @quitting
 
   # Public: Adds the {AtomWindow} to the global window list.
   addWindow: (window) ->

    @openPathOnEvent('application:open-your-stylesheet', 'atom://.atom/stylesheet')
    @openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md'))

    app.on 'will-quit', =>
      @killAllProcesses()
      @deleteSocketFile()

  atomProtocolHandler: null
  resourcePath: null
  version: null
  quitting: false

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

