diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index 815298d3d9de..623827cd2a3f 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -465,6 +465,9 @@ ipcMain.on('ELECTRON_BROWSER_WINDOW_CONFIRM', function (event, message, title) { // Implements window.close() ipcMain.on('ELECTRON_BROWSER_WINDOW_CLOSE', function (event) { - event.sender.getOwnerBrowserWindow().close() + const window = event.sender.getOwnerBrowserWindow() + if (window) { + window.close() + } event.returnValue = null })