diff options
| -rw-r--r-- | gui/src/main/index.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 4f398d208d..c39ccdbc5c 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -310,6 +310,7 @@ class ApplicationMain { app.on('ready', this.onReady); app.on('window-all-closed', () => app.quit()); app.on('before-quit', this.onBeforeQuit); + app.on('quit', this.onQuit); } private addSecondInstanceEventHandler() { @@ -382,6 +383,14 @@ class ApplicationMain { } }; + // This is a last try to disconnect and quit gracefully if the app quits without having received + // the before-quit event. + private onQuit = async () => { + if (this.quitStage !== AppQuitStage.ready) { + await this.prepareToQuit(); + } + }; + private onBeforeQuit = async (event: Electron.Event) => { switch (this.quitStage) { case AppQuitStage.unready: |
