Repository: vscode
Issue: `workbench.action.closeWindow` sporadically causes crash, closing all open VS Code instances
Labels: freeze-slow-crash-leak,windows

Type: <b>Bug</b>

&nbsp;  
Issue occurs when using the default `alt+f4` keybinding to execute `workbench.action.closeWindow`.  The issue is sporadic, the `closeWindow` action triggers successfully several times before causing the crash.

<details>
  <summary>Error Event 1</summary>
  
  ```xml
  Log Name:      Application
  Source:        .NET Runtime
  Date:          2/29/2024 2:36:27 AM
  Event ID:      1026
  Task Category: None
  Level:         Error
  Keywords:      Classic
  User:          N/A
  Computer:      Desktop
  Description:
  Application: Code.exe
  Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: exception code c0000005, exception address 00007FF6FDEBA8F7

  Event Xml:
  <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
      <Provider Name=".NET Runtime" />
      <EventID Qualifiers="0">1026</EventID>
      <Version>0</Version>
      <Level>2</Level>
      <Task>0</Task>
      <Opcode>0</Opcode>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated SystemTime="2024-02-29T07:36:27.6945431Z" />
      <EventRecordID>1772168</EventRecordID>
      <Correlation />
      <Execution ProcessID="0" ThreadID="0" />
      <Channel>Application</Channel>
      <Computer>Desktop</Computer>
      <Security />
    </System>
    <EventData>
      <Data>Application: Code.exe
  Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: exception code c0000005, exception address 00007FF6FDEBA8F7
  </Data>
    </EventData>
  </Event>
  ```
</details>

<details>
  <summary>Error Event 2</summary>
  
  ```xml
  Log Name:      Application
  Source:        Application Error
  Date:          2/29/2024 2:36:28 AM
  Event ID:      1000
  Task Category: (100)
  Level:         Error
  Keywords:      Classic
  User:          N/A
  Computer:      Desktop
  Description:
  Faulting application name: Code.exe, version: 1.87.0.0, time stamp: 0x6564f1e7
  Faulting module name: Code.exe, version: 1.87.0.0, time stamp: 0x6564f1e7
  Exception code: 0xc000041d
  Fault offset: 0x00000000041aa8f7
  Faulting process id: 0x3d44
  Faulting application start time: 0x01da6ad374bbde54
  Faulting application path: D:\Portable\VS-Code\Code.exe
  Faulting module path: D:\Portable\VS-Code\Code.exe
  Report Id: e6ee78f2-1a5f-4081-b102-7c1587b9bb7e
  Faulting package full name: 
  Faulting package-relative application ID: 
  Event Xml:
  <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
      <Provider Name="Application Error" />
      <EventID Qualifiers="0">1000</EventID>
      <Version>0</Version>
      <Level>2</Level>
      <Task>100</Task>
      <Opcode>0</Opcode>
      <Keywords>0x80000000000000</Keywords>
      <TimeCreated SystemTime="2024-02-29T07:36:28.0920426Z" />
      <EventRecordID>1772169</EventRecordID>
      <Correlation />
      <Execution ProcessID="0" ThreadID="0" />
      <Channel>Application</Channel>
      <Computer>Desktop</Computer>
      <Security />
    </System>
    <EventData>
      <Data>Code.exe</Data>
      <Data>1.87.0.0</Data>
      <Data>6564f1e7</Data>
      <Data>Code.exe</Data>
      <Data>1.87.0.0</Data>
      <Data>6564f1e7</Data>
      <Data>c000041d</Data>
      <Data>00000000041aa8f7</Data>
      <Data>3d44</Data>
      <Data>01da6ad374bbde54</Data>
      <Data>D:\Portable\VS-Code\Code.exe</Data>
      <Data>D:\Portable\VS-Code\Code.exe</Data>
      <Data>e6ee78f2-1a5f-4081-b102-7c1587b9bb7e</Data>
      <Data>
      </Data>
      <Data>
      </Data>
    </EventData>
  </Event>
  ```
</details>

[Crash Report.zip](https://github.com/microsoft/vscode/files/14459476/Crash.Report.zip)

---------------------------------------------------------

### Report Info

VS Code version: Code 1.87.0 (019f4d1419fbc8219a181fab7892ebccf7ee29a2, 2024-02-27T23:41:44.469Z)
OS version: Windows_NT x64 10.0.19045
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz (8 x 4008)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|undefined|
|Memory (System)|63.96GB (38.10GB free)|
|Process Argv|--new-window|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (74)</summary>

Extension|Author (truncated)|Version
---|---|---
svelte-bundle|1Yi|1.0.0
enteleform--language--separator-file|ent|1.0.0
enteleform--dsl-cycler|ent|1.0.0
enteleform--development|ent|1.0.0
restore-editors|amo|1.0.1
svelte-intellisense|ard|0.7.1
astro-vscode|ast|2.7.5
es6-string-css|bas|0.1.0
vscode-custom-css|be5|7.2.1
path-intellisense|chr|2.8.5
indent4to2|Com|0.1.2
macros|ctf|1.0.0
cat-customs|vsc|0.0.1
permute-lines|ear|1.1.0
sort-lines-by-selection|ear|1.2.0
prettier-vscode|esb|10.1.0
comment-anchors|Exo|1.10.4
vscode-terminals|fab|1.15.0
vscode-firefox-debug|fir|2.9.10
vscode-svelte-snippets|fiv|0.5.0
cursoruler|fre|0.0.4
copilot|Git|1.168.0
copilot-chat|Git|0.13.0
asciidecorator|hel|0.3.0
vscode-settings-cycler|hoo|1.0.1
vscode-npm-dependency|how|1.2.2
reg|ion|1.1.0
search-editor-apply-changes|jak|0.1.1
code-select-until|jak|0.6.0
align-by-regex|jan|1.0.4
vscode-text-pastry|jkj|1.3.1
langium-vscode|lan|2.1.0
vscode-fix-checksums|leh|1.1.0
quicktask|lky|3.5.8
vscode-autohotkey-plus-plus|mar|5.0.3
vscode-edge-devtools|ms-|2.1.4
debugpy|ms-|2024.2.0
python|ms-|2024.2.0
vscode-pylance|ms-|2024.2.2
remote-ssh|ms-|0.109.0
remote-ssh-edit|ms-|0.86.0
remote-wsl|ms-|0.86.0
js-debug-nightly|ms-|2024.2.2817
powershell|ms-|2024.0.0
remote-explorer|ms-|0.4.3
vscode-speech|ms-|0.6.0
vsliveshare|ms-|1.0.5905
vsliveshare-pack|ms-|0.4.0
debugger-for-edge|msj|1.0.15
sftp|Nat|1.16.3
es6-string-yaml|nat|1.0.1
color-highlight|nau|2.5.0
notifications-sample|und|0.0.1
vscode-xyplorer|Oti|0.2.1
vscode-subword-navigation|ow|1.2.0
subtle-brackets|raf|3.0.0
es6-string-jsx|Raz|1.0.0
vscode-yaml|red|1.14.0
exchange-selection-start-end|san|2.0.4
comment-box|Sly|2.3.0
code-spell-checker|str|3.0.1
svelte-vscode|sve|108.3.1
language-stylus|sys|1.16.0
even-better-toml|tam|0.19.2
vscode-lezer|tam|0.14.0
duplicate-finder|tle|0.0.6
pdf|tom|1.2.2
selectline-statusbar|tom|0.0.2
tree-sitter-graph|tre|0.1.1
sort-lines|Tyr|1.11.0
change-case|wma|1.0.0
cursor-align|yo1|1.1.2
vscode-autohotkey-debug|zer|1.11.0
es6-string-javascript|zjc|1.0.1

(2 theme extensions excluded)

</details>
<!-- generated by issue reporter -->