[PR #13614] Manually quit when the OS tells us to update #29663

Open
opened 2026-01-31 09:36:12 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13614

State: closed
Merged: Yes


Refer to https://docs.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications

The OS will send us a WM_QUERYENDSESSION when it's preparing an
update for our app. It will then send us a WM_ENDSESSION, which gives
us a small timeout (~30s) to actually shut down gracefully. After
that timeout, it will send us a WM_CLOSE. If we still don't close
after the WM_CLOSE, it'll force-kill us (causing a crash which will be
bucketed to moapphang).

We will manually start a quit, so that we can persist the state. If we refuse to
gracefully shut down, the OS will crash us to focefully terminate us. We
choose to quit here, rather than just close, to skip over any warning dialogs
(e.g. "Are you sure you want to close all tabs?") which might prevent a WM_CLOSE
from cleanly closing the window.

This will cause a appHost._RequestQuitAll, which will notify the
monarch to collect up all the window state and save it.

This "crash" caused by the OS force killing us constitutes 80% of all our crashes. 80%. See MSFT:38947155, MSFT:38877540, MSFT:21058878, MSFT:31710054, MSFT:39764652, MSFT:26883776.

Closes #13569

It also fixes the issue where if you've got Terminal Dev running (outside VS), and you try to Deploy, you have to make sure to close the "Are you sure you want to close all tabs" dialog before the deployment can proceed. A deploy in VS sends the same sequence of messages as a real update.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/13614 **State:** closed **Merged:** Yes --- Refer to https://docs.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications The OS will send us a WM_QUERYENDSESSION when it's preparing an update for our app. It will then send us a WM_ENDSESSION, which gives us a small timeout (~30s) to actually shut down gracefully. After that timeout, it will send us a WM_CLOSE. If we still don't close after the WM_CLOSE, it'll force-kill us (causing a crash which will be bucketed to moapphang). We will manually start a quit, so that we can persist the state. If we refuse to gracefully shut down, the OS will crash us to focefully terminate us. We choose to quit here, rather than just close, to skip over any warning dialogs (e.g. "Are you sure you want to close all tabs?") which might prevent a WM_CLOSE from cleanly closing the window. This will cause a appHost._RequestQuitAll, which will notify the monarch to collect up all the window state and save it. This "crash" caused by the OS force killing us constitutes 80% of all our crashes. 80%. See MSFT:38947155, MSFT:38877540, MSFT:21058878, MSFT:31710054, MSFT:39764652, MSFT:26883776. Closes #13569 It also fixes the issue where if you've got Terminal Dev running (outside VS), and you try to Deploy, you have to make sure to close the "Are you sure you want to close all tabs" dialog before the deployment can proceed. A deploy in VS sends the same sequence of messages as a real update.
claunia added the pull-request label 2026-01-31 09:36:12 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29663