<p dir="auto">The parent window will unexpectedly show itself if a child window is shown. I noticed this issue when my apps main window would reveal itself sooner than expected behind the splash screen.</p>
<ul dir="auto">
<li>OS - MacOS Big Sur</li>
<li>Electron - 13.1.2
<ul dir="auto">
<li>This is not an issue in electron 12</li>
</ul>
</li>
</ul>
<p dir="auto">Here is example code to reproduce the issue -</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const {app, BrowserWindow} = require('electron');

function createWindow() {
   const win = new BrowserWindow({
      width: 800,
      height: 600,
      show: false
   });

   const child = new BrowserWindow({
      parent: win,
      width: 400,
      height: 300,
      show: false,
      backgroundColor: '#4f4f4f'
   })

   child.loadFile('child.html').then(() =&gt; {
      child.show();
      setTimeout(() =&gt; {
         win.loadFile('index.html').then(() =&gt; {
            win.show();
            child.close();
         });
      }, 5000);
   });

}

app.whenReady().then(() =&gt; {
   createWindow();
});"><pre class="notranslate"><code class="notranslate">const {app, BrowserWindow} = require('electron');

function createWindow() {
   const win = new BrowserWindow({
      width: 800,
      height: 600,
      show: false
   });

   const child = new BrowserWindow({
      parent: win,
      width: 400,
      height: 300,
      show: false,
      backgroundColor: '#4f4f4f'
   })

   child.loadFile('child.html').then(() =&gt; {
      child.show();
      setTimeout(() =&gt; {
         win.loadFile('index.html').then(() =&gt; {
            win.show();
            child.close();
         });
      }, 5000);
   });

}

app.whenReady().then(() =&gt; {
   createWindow();
});
</code></pre></div>
<ul dir="auto">
<li>Output of <code class="notranslate">node_modules/.bin/electron --version</code>: 3.0.4</li>
<li>Operating System (Platform and Version): Windows 10.0.14393 (also repros on Win7)</li>
<li>Output of <code class="notranslate">node_modules/.bin/electron --version</code> on last known working Electron version (if applicable): Unknown</li>
</ul>
<p dir="auto"><strong>This issue only manifests when running Electron as a non-admin user</strong></p>
<p dir="auto"><strong>Expected Behavior</strong><br>
Calls to BrowserWindow.close() should not crash the application.</p>
<p dir="auto"><strong>Actual behavior</strong><br>
Application crashes when user closes the BrowserWindow.</p>
<p dir="auto"><strong>To Reproduce</strong><br>
I reproduced this using electron-quick-start <a href="https://github.com/jameskoch/electron-quick-start/commit/69ee8609ab90e00536da4a06c1a24d54cb71e15b">here</a>.</p>
<ol dir="auto">
<li>On Windows, make sure you're using a non-admin account.</li>
<li>git clone; npm install; npm start;</li>
<li>Click the X in the top right hand corner of the BrowserWindow</li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ git clone https://github.com/jameskoch/electron-quick-start
$ npm install
$ npm start"><pre class="notranslate">$ git clone https://github.com/jameskoch/electron-quick-start
$ npm install
$ npm start</pre></div>
<p dir="auto"><strong>Additional Information</strong><br>
Note that this code works fine when run as an administrator.</p>
<p dir="auto">This appears in the Windows Application Event Log with exception code/offset:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception code: 0xc0000005
Fault offset: 0x00000000018727f4"><pre class="notranslate"><code class="notranslate">Exception code: 0xc0000005
Fault offset: 0x00000000018727f4
</code></pre></div>
<p dir="auto">On a different machine, using my full app (Electron 3.0.5), I loaded symbols and got a bit more info:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nteract.exe!aura::Window::GetRootWindow() Line 212   C++
nteract.exe!aura::Window::GetHost() Line 216    C++
nteract.exe!atom::NativeWindowViews::GetAcceleratedWidget() Line 1028          C++
nteract.exe!atom::NativeWindowViews::IsClosable() Line 686      C++
nteract.exe!atom::NativeWindowViews::Close() Line 314               C++
nteract.exe!mate::internal::Dispatcher&lt;void __cdecl(atom::api::Menu * __ptr64)&gt;::DispatchToCallback(const v8::FunctionCallbackInfo&lt;v8::Value&gt; &amp; info) Line 239       C++
node.dll!000007fec5e0de84()     Unknown
node.dll!000007fec5e7f8fd()      Unknown
node.dll!000007fec5e4db89()     Unknown
node.dll!000007fec5e4da6b()     Unknown
0000000c95f84561()        Unknown"><pre class="notranslate"><code class="notranslate">nteract.exe!aura::Window::GetRootWindow() Line 212   C++
nteract.exe!aura::Window::GetHost() Line 216    C++
nteract.exe!atom::NativeWindowViews::GetAcceleratedWidget() Line 1028          C++
nteract.exe!atom::NativeWindowViews::IsClosable() Line 686      C++
nteract.exe!atom::NativeWindowViews::Close() Line 314               C++
nteract.exe!mate::internal::Dispatcher&lt;void __cdecl(atom::api::Menu * __ptr64)&gt;::DispatchToCallback(const v8::FunctionCallbackInfo&lt;v8::Value&gt; &amp; info) Line 239       C++
node.dll!000007fec5e0de84()     Unknown
node.dll!000007fec5e7f8fd()      Unknown
node.dll!000007fec5e4db89()     Unknown
node.dll!000007fec5e4da6b()     Unknown
0000000c95f84561()        Unknown
</code></pre></div>
<p dir="auto">Perhaps this is just a nonsense usage of beforequit. My goal was to orchestrate an orderly shutdown of each open BrowserWindow before the application itself terminates. I developed this code on macOS, and was primarily targeting the "Command + Q" workflow when using beforequit.</p>