If you're using context isolation as recommended by Electron, each window should have its own context and window object. That would prevent the leak as each window object is separate and would be removed alongside the closed window.