From 60845b787062dbc48bbf9ed85c2f551131015fb5 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Sun, 26 Apr 2026 10:34:42 -0700 Subject: [PATCH] Bypass beforeunload on window close so app quits while audio plays --- desktop-client/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/desktop-client/index.js b/desktop-client/index.js index 94ddacd..a054e1b 100644 --- a/desktop-client/index.js +++ b/desktop-client/index.js @@ -26,6 +26,15 @@ async function createWindow() { }, }); + mainWindow.on('close', (e) => { + // Bypass beforeunload (YT Music sets one while audio is playing) so the + // window actually closes when the user clicks X or chooses Quit. + if (mainWindow && !mainWindow.isDestroyed()) { + e.preventDefault(); + mainWindow.destroy(); + } + }); + mainWindow.on('closed', () => { mainWindow = null; });