Skip to content

Inconsistent behavior between app.quit and un-closable BrowserWindow #5680

Closed

Description

@djpereira
  • Electron version: 1.1.1
  • Operating system: OSX 10.11.4 (El Capitan)

If you create a BrowserWindow and set BrowserWindowOptions.closable, calling app.quit does not close the application in OSX. AFAIK, it is expected that calling app.quit() closes the app irrespectively of how the windows are built.

The behavior is not observed in Windows, only OSX. To quit the app in OSX, you need go to the dock, right click on the app and select Quit twice.

Activity

  1. danhp commented on May 24, 2016

    @danhp
    Contributor

    app.quit() will try to close all browser windows before exiting. But since they aren't closable it can't quit. You can instead use app.exit(exitCode) to bypass the checks.

  2. zcbenz commented on May 25, 2016

    @zcbenz
    Contributor

    I think there are two bugs here:

    • On Windows app.quit can close a window that marked as not closable.
    • On OS X calling app.quit twice can ignore the un-closable windows.
  3. changed the title [-]app.quit does not close application in OSX when BrowserWindowOptions.closable is set to false.[/-] [+]Inconsistent behavior between app.quit and un-closable BrowserWindow[/+] on May 25, 2016
  4. MarshallOfSound commented on May 25, 2016

    @MarshallOfSound
    Member

    @zcbenz I feel as though app.quit should be able to close un-closable windows. Or at least add a force parameter that ignore unclosable windows. Purely because if I call app.quit() as @djpereira said

    it is expected that calling app.quit() closes the app irrespectively of how the windows are built.

    Calling window.close() should obviously fail, but calling app.quit() I feel shouldn't care about "windows" per say, rather it is trying to terminate the app as a whole?

  5. zcbenz commented on May 25, 2016

    @zcbenz
    Contributor

    The behavior of app.quit() is to first close all windows and then try to quit, and it will be canceled when a window refuses to closed. It is a request to quit, for force quitting there is app.exit.

  6. MarshallOfSound commented on May 25, 2016

    @MarshallOfSound
    Member

    Wow, I must have the the app doc page so many times and never seen that .exit() method... I cry 😢

  7. schroef commented on Dec 28, 2019

    @schroef

    Does anyone know why the code below causes inconsistent behavior with quitting the app with cmd+q. Yet the app stays active when close buttons is pressed. But know users on OSX need to press cmd+q twice, the regular quite from the menu doesnt actually quit the app no more, it only closes the main window?

    // Quit when all windows are closed.
    app.on('window-all-closed', () => {
      if (!(clipServer && clipServer.isRunInBackgroundEnabled())) {
        // On OS X it is common for applications and their menu bar
        // to stay active until the user quits explicitly with Cmd + Q
        if (process.platform !== 'darwin') {
          app.quit();
        }
      }
    });
    

    The main application menu has a quit command which now needs to be used twice due to this code??? This menu is added by default by electron

    Screen Shot 2019-12-28 at 16 33 27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions