<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>9.1.0</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 10 (19041, 18363, 18362, 16299)</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>N/A</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">The application should not crash.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">The application crashes.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">This seems happening sporadically when application exits (all windows get closed, destroyed and app is quit).<br>
It happens only on Windows, MacOS does not seem to affected.<br>
My code snippet:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  app.removeAllListeners('window-all-closed')
  BrowserWindow.getAllWindows().forEach((browserWindow) =&gt; {
    browserWindow.close()
    browserWindow.destroy()
  })
  app.quit()"><pre class="notranslate"><code class="notranslate">  app.removeAllListeners('window-all-closed')
  BrowserWindow.getAllWindows().forEach((browserWindow) =&gt; {
    browserWindow.close()
    browserWindow.destroy()
  })
  app.quit()
</code></pre></div>



<h3 dir="auto">Stack Trace</h3>
<p dir="auto">Pastebin: <a href="https://pastebin.com/raw/MYvbpWe2" rel="nofollow">https://pastebin.com/raw/MYvbpWe2</a><br>
Snippet:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ

Thread 10196 Crashed:
0   MyApp.exe                     0x7ff75f43a632      [inlined] base::internal::UncheckedObserverAdapter::IsEqual (observer_list_internal.h:30)
1   MyApp.exe                     0x7ff75f43a632      [inlined] base::ObserverList&lt;T&gt;::RemoveObserver::&lt;T&gt;::operator() (observer_list.h:283)
2   MyApp.exe                     0x7ff75f43a632      [inlined] std::__1::find_if (algorithm:933)
3   MyApp.exe                     0x7ff75f43a632      base::ObserverList&lt;T&gt;::RemoveObserver (observer_list.h:281)
4   MyApp.exe                     0x7ff76101f28c      extensions::ProcessManager::Shutdown (process_manager.cc:289)
5   MyApp.exe                     0x7ff761e3a08d      [inlined] DependencyManager::ShutdownFactoriesInOrder (dependency_manager.cc:127)
6   MyApp.exe                     0x7ff761e3a08d      DependencyManager::DestroyContextServices (dependency_manager.cc:83)
7   MyApp.exe                     0x7ff75f2e8de6      electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:158)
8   MyApp.exe                     0x7ff75f2e9abf      electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:154)
9   MyApp.exe                     0x7ff75f287a9d      [inlined] base::RefCountedDeleteOnSequence&lt;T&gt;::Release (ref_counted_delete_on_sequence.h:52)
10  MyApp.exe                     0x7ff75f287a9d      [inlined] scoped_refptr&lt;T&gt;::Release (scoped_refptr.h:322)
11  MyApp.exe                     0x7ff75f287a9d      [inlined] scoped_refptr&lt;T&gt;::~scoped_refptr (scoped_refptr.h:224)
12  MyApp.exe                     0x7ff75f287a9d      electron::api::Session::~Session (electron_api_session.cc:313)
13  MyApp.exe                     0x7ff75f28cdaf      electron::api::Session::~Session (electron_api_session.cc:294)
14  MyApp.exe                     0x7ff75f2eb641      [inlined] base::OnceCallback&lt;T&gt;::Run (callback.h:98)
15  MyApp.exe                     0x7ff75f2eb641      electron::ElectronBrowserMainParts::PostMainMessageLoopRun (electron_browser_main_parts.cc:545)
16  MyApp.exe                     0x7ff760a01750      content::BrowserMainLoop::ShutdownThreadsAndCleanUp (browser_main_loop.cc:1095)
17  MyApp.exe                     0x7ff760a031a6      content::BrowserMainRunnerImpl::Shutdown (browser_main_runner_impl.cc:178)
18  MyApp.exe                     0x7ff7609fee69      content::BrowserMain (browser_main.cc:49)
19  MyApp.exe                     0x7ff76090405c      content::RunBrowserProcessMain (content_main_runner_impl.cc:530)
20  MyApp.exe                     0x7ff760904c00      content::ContentMainRunnerImpl::RunServiceManager (content_main_runner_impl.cc:980)
21  MyApp.exe                     0x7ff7609048c2      content::ContentMainRunnerImpl::Run (content_main_runner_impl.cc:879)
22  MyApp.exe                     0x7ff761870252      service_manager::Main (main.cc:454)
23  MyApp.exe                     0x7ff75fcd8265      content::ContentMain (content_main.cc:19)
24  MyApp.exe                     0x7ff75f23140a      wWinMain (electron_main.cc:210)
25  MyApp.exe                     0x7ff7646a6e91      [inlined] invoke_main (exe_common.inl:118)
26  MyApp.exe                     0x7ff7646a6e91      __scrt_common_main_seh (exe_common.inl:288)
27  KERNEL32.DLL                    0x7ffed8a97033      BaseThreadInitThunk
28  ntdll.dll                       0x7ffed97dcec0      RtlUserThreadStart"><pre class="notranslate"><code class="notranslate">Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ

Thread 10196 Crashed:
0   MyApp.exe                     0x7ff75f43a632      [inlined] base::internal::UncheckedObserverAdapter::IsEqual (observer_list_internal.h:30)
1   MyApp.exe                     0x7ff75f43a632      [inlined] base::ObserverList&lt;T&gt;::RemoveObserver::&lt;T&gt;::operator() (observer_list.h:283)
2   MyApp.exe                     0x7ff75f43a632      [inlined] std::__1::find_if (algorithm:933)
3   MyApp.exe                     0x7ff75f43a632      base::ObserverList&lt;T&gt;::RemoveObserver (observer_list.h:281)
4   MyApp.exe                     0x7ff76101f28c      extensions::ProcessManager::Shutdown (process_manager.cc:289)
5   MyApp.exe                     0x7ff761e3a08d      [inlined] DependencyManager::ShutdownFactoriesInOrder (dependency_manager.cc:127)
6   MyApp.exe                     0x7ff761e3a08d      DependencyManager::DestroyContextServices (dependency_manager.cc:83)
7   MyApp.exe                     0x7ff75f2e8de6      electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:158)
8   MyApp.exe                     0x7ff75f2e9abf      electron::ElectronBrowserContext::~ElectronBrowserContext (electron_browser_context.cc:154)
9   MyApp.exe                     0x7ff75f287a9d      [inlined] base::RefCountedDeleteOnSequence&lt;T&gt;::Release (ref_counted_delete_on_sequence.h:52)
10  MyApp.exe                     0x7ff75f287a9d      [inlined] scoped_refptr&lt;T&gt;::Release (scoped_refptr.h:322)
11  MyApp.exe                     0x7ff75f287a9d      [inlined] scoped_refptr&lt;T&gt;::~scoped_refptr (scoped_refptr.h:224)
12  MyApp.exe                     0x7ff75f287a9d      electron::api::Session::~Session (electron_api_session.cc:313)
13  MyApp.exe                     0x7ff75f28cdaf      electron::api::Session::~Session (electron_api_session.cc:294)
14  MyApp.exe                     0x7ff75f2eb641      [inlined] base::OnceCallback&lt;T&gt;::Run (callback.h:98)
15  MyApp.exe                     0x7ff75f2eb641      electron::ElectronBrowserMainParts::PostMainMessageLoopRun (electron_browser_main_parts.cc:545)
16  MyApp.exe                     0x7ff760a01750      content::BrowserMainLoop::ShutdownThreadsAndCleanUp (browser_main_loop.cc:1095)
17  MyApp.exe                     0x7ff760a031a6      content::BrowserMainRunnerImpl::Shutdown (browser_main_runner_impl.cc:178)
18  MyApp.exe                     0x7ff7609fee69      content::BrowserMain (browser_main.cc:49)
19  MyApp.exe                     0x7ff76090405c      content::RunBrowserProcessMain (content_main_runner_impl.cc:530)
20  MyApp.exe                     0x7ff760904c00      content::ContentMainRunnerImpl::RunServiceManager (content_main_runner_impl.cc:980)
21  MyApp.exe                     0x7ff7609048c2      content::ContentMainRunnerImpl::Run (content_main_runner_impl.cc:879)
22  MyApp.exe                     0x7ff761870252      service_manager::Main (main.cc:454)
23  MyApp.exe                     0x7ff75fcd8265      content::ContentMain (content_main.cc:19)
24  MyApp.exe                     0x7ff75f23140a      wWinMain (electron_main.cc:210)
25  MyApp.exe                     0x7ff7646a6e91      [inlined] invoke_main (exe_common.inl:118)
26  MyApp.exe                     0x7ff7646a6e91      __scrt_common_main_seh (exe_common.inl:288)
27  KERNEL32.DLL                    0x7ffed8a97033      BaseThreadInitThunk
28  ntdll.dll                       0x7ffed97dcec0      RtlUserThreadStart
</code></pre></div>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">This seems a crash on shutdown/destroy of windows (from <code class="notranslate">base::Process::Terminate (process_win.cc)</code>, not sure if it's chromium-related (<a href="https://chromium.googlesource.com/chromium/src/+/master/docs/shutdown.md" rel="nofollow">https://chromium.googlesource.com/chromium/src/+/master/docs/shutdown.md</a>)</p>
<p dir="auto">Detected in CI: <a href="https://app.circleci.com/pipelines/github/electron/electron/31161/workflows/e022a2a8-d5fb-47b4-806f-84f69ecf0a8a/jobs/686542" rel="nofollow">https://app.circleci.com/pipelines/github/electron/electron/31161/workflows/e022a2a8-d5fb-47b4-806f-84f69ecf0a8a/jobs/686542</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Received signal 11 SEGV_MAPERR ffffffffffffffff
0   Electron Framework                  0x0000000114bcb869 base::debug::CollectStackTrace(void**, unsigned long) + 9
1   Electron Framework                  0x0000000114ac6203 base::debug::StackTrace::StackTrace() + 19
2   Electron Framework                  0x0000000114bcb731 base::debug::(anonymous namespace)::StackDumpSignalHandler(int, __siginfo*, void*) + 2385
3   libsystem_platform.dylib            0x00007fff6fcda5fd _sigtramp + 29
4   ???                                 0x00007ff9fa10d6e0 0x0 + 140711618991840
5   Electron Framework                  0x0000000114710a51 extensions::ProcessManager::Shutdown() + 33
6   Electron Framework                  0x000000011651d4fc DependencyManager::DestroyContextServices(void*) + 140
7   Electron Framework                  0x000000010f34d708 electron::ElectronBrowserContext::~ElectronBrowserContext() + 184
8   Electron Framework                  0x000000010f34d9fe electron::ElectronBrowserContext::~ElectronBrowserContext() + 14
9   Electron Framework                  0x000000010f35160d std::__1::__tree&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::__map_value_compare&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::less&lt;electron::ElectronBrowserContext::PartitionKey&gt;, true&gt;, std::__1::allocator&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt; &gt; &gt;::destroy(std::__1::__tree_node&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, void*&gt;*) + 61
10  Electron Framework                  0x000000010f3515f6 std::__1::__tree&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::__map_value_compare&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::less&lt;electron::ElectronBrowserContext::PartitionKey&gt;, true&gt;, std::__1::allocator&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt; &gt; &gt;::destroy(std::__1::__tree_node&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, void*&gt;*) + 38
11  Electron Framework                  0x000000010f35121b electron::ElectronBrowserMainParts::PostMainMessageLoopRun() + 219
12  Electron Framework                  0x00000001134a7477 content::BrowserMainLoop::ShutdownThreadsAndCleanUp() + 647
13  Electron Framework                  0x00000001134a9510 content::BrowserMainRunnerImpl::Shutdown() + 224
14  Electron Framework                  0x00000001134a3c57 content::BrowserMain(content::MainFunctionParams const&amp;) + 279
15  Electron Framework                  0x00000001132bd757 content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams&amp;, bool) + 1191
16  Electron Framework                  0x00000001132bd283 content::ContentMainRunnerImpl::Run(bool) + 467
17  Electron Framework                  0x00000001110e92be content::RunContentProcess(content::ContentMainParams const&amp;, content::ContentMainRunner*) + 2782
18  Electron Framework                  0x00000001110e93ac content::ContentMain(content::ContentMainParams const&amp;) + 44
19  Electron Framework                  0x000000010f2285a9 ElectronMain + 137
20  Electron                            0x0000000108e99631 main + 289
21  libdyld.dylib                       0x00007fff6faddcc9 start + 1
[end of stack trace]"><pre class="notranslate"><code class="notranslate">Received signal 11 SEGV_MAPERR ffffffffffffffff
0   Electron Framework                  0x0000000114bcb869 base::debug::CollectStackTrace(void**, unsigned long) + 9
1   Electron Framework                  0x0000000114ac6203 base::debug::StackTrace::StackTrace() + 19
2   Electron Framework                  0x0000000114bcb731 base::debug::(anonymous namespace)::StackDumpSignalHandler(int, __siginfo*, void*) + 2385
3   libsystem_platform.dylib            0x00007fff6fcda5fd _sigtramp + 29
4   ???                                 0x00007ff9fa10d6e0 0x0 + 140711618991840
5   Electron Framework                  0x0000000114710a51 extensions::ProcessManager::Shutdown() + 33
6   Electron Framework                  0x000000011651d4fc DependencyManager::DestroyContextServices(void*) + 140
7   Electron Framework                  0x000000010f34d708 electron::ElectronBrowserContext::~ElectronBrowserContext() + 184
8   Electron Framework                  0x000000010f34d9fe electron::ElectronBrowserContext::~ElectronBrowserContext() + 14
9   Electron Framework                  0x000000010f35160d std::__1::__tree&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::__map_value_compare&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::less&lt;electron::ElectronBrowserContext::PartitionKey&gt;, true&gt;, std::__1::allocator&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt; &gt; &gt;::destroy(std::__1::__tree_node&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, void*&gt;*) + 61
10  Electron Framework                  0x000000010f3515f6 std::__1::__tree&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::__map_value_compare&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, std::__1::less&lt;electron::ElectronBrowserContext::PartitionKey&gt;, true&gt;, std::__1::allocator&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt; &gt; &gt;::destroy(std::__1::__tree_node&lt;std::__1::__value_type&lt;electron::ElectronBrowserContext::PartitionKey, std::__1::unique_ptr&lt;electron::ElectronBrowserContext, std::__1::default_delete&lt;electron::ElectronBrowserContext&gt; &gt; &gt;, void*&gt;*) + 38
11  Electron Framework                  0x000000010f35121b electron::ElectronBrowserMainParts::PostMainMessageLoopRun() + 219
12  Electron Framework                  0x00000001134a7477 content::BrowserMainLoop::ShutdownThreadsAndCleanUp() + 647
13  Electron Framework                  0x00000001134a9510 content::BrowserMainRunnerImpl::Shutdown() + 224
14  Electron Framework                  0x00000001134a3c57 content::BrowserMain(content::MainFunctionParams const&amp;) + 279
15  Electron Framework                  0x00000001132bd757 content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams&amp;, bool) + 1191
16  Electron Framework                  0x00000001132bd283 content::ContentMainRunnerImpl::Run(bool) + 467
17  Electron Framework                  0x00000001110e92be content::RunContentProcess(content::ContentMainParams const&amp;, content::ContentMainRunner*) + 2782
18  Electron Framework                  0x00000001110e93ac content::ContentMain(content::ContentMainParams const&amp;) + 44
19  Electron Framework                  0x000000010f2285a9 ElectronMain + 137
20  Electron                            0x0000000108e99631 main + 289
21  libdyld.dylib                       0x00007fff6faddcc9 start + 1
[end of stack trace]
</code></pre></div>