diff --git a/lib/gui/etcher.js b/lib/gui/etcher.js index aad2cac0..7ee51c79 100644 --- a/lib/gui/etcher.js +++ b/lib/gui/etcher.js @@ -19,10 +19,21 @@ const electron = require('electron'); const _ = require('lodash'); const path = require('path'); +const EXIT_CODES = require('../shared/exit-codes'); let mainWindow = null; electron.app.on('window-all-closed', electron.app.quit); +// Sending a `SIGINT` (e.g: Ctrl-C) to an Electron app that registers +// a `beforeunload` window event handler results in a disconnected white +// browser window in GNU/Linux and macOS. +// The `before-quit` Electron event is triggered in `SIGINT`, so we can +// make use of it to ensure the browser window is completely destroyed. +// See https://github.com/electron/electron/issues/5273 +electron.app.on('before-quit', () => { + process.exit(EXIT_CODES.SUCCESS); +}); + electron.app.on('ready', () => { // No menu bar