Boliang ZhangandCopilot b9c2d3c1c5 fix(runner): unload modules before CRT teardown (#51433)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Restore Hybrid CRT together with the Runner shutdown fix for the
tray-Quit process hang introduced by #50899. Without explicit early
cleanup, Runner's static module-map destruction can hold the shared UCRT
exit lock while waiting for a module worker that needs that same lock.

Main temporarily disabled Hybrid CRT through #51432. This PR now
reverses that rollback **in the same change as the shutdown fix**,
completing module shutdown before CRT teardown and before releasing
Runner's lifetime guards. The rollback reversal must not be merged
independently of the fix.

The original three commits were rebased onto main
`e7afd3fa439906a8e4ff4388a961511ca5cf81e7` without conflicts or patch
changes, followed by the exact revert of #51432. The combined fix was
validated at `d62d5e004e70a1f8a4eaca7f591fab8bf7eebd8f`; follow-ups
remove both `runner.md` changes and the manual shutdown-check script
from this PR without changing product code. Stable and the published
0.102 release are not changed.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: N/A; regression introduced by #50899, restoring Hybrid CRT
after the mitigation in #51432
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass — existing native tests and
prior manual shutdown checks passed; no new automated test is retained
in this PR, and broader restart/elevation/session-ending runtime
coverage remains incomplete
- [x] **Localization:** All end-user-facing strings can be localized —
no new end-user strings
- [x] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places — N/A, no new
shipping binaries
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: N/A; repository developer documentation only

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

- `src\runner\main.cpp`: a local cleanup guard cancels deferred Settings
startup, stops the centralized hook, revokes module hotkey callbacks,
and clears the module map before the settings-CLI and single-instance
guards are released. It covers ordinary exit and exception unwinding as
well as restart; the old restart-only clear is removed.
- `src\runner\centralized_hotkeys.cpp`: revoke every matching callback
and avoid trying to unregister window-owned hotkeys after their window
has been destroyed.
- Advanced Paste and PowerDisplay process-manager headers: declare the
executor last so its worker joins before the pipe/state accessed by its
tasks is destroyed.
- `Cpp.Build.props` and `doc\devdocs\development\guidelines.md`: exactly
revert `cf45de4118c22dbe80a2aa55c6ea0935ea7e2b3b` (#51432), restoring
the shared-UCRT default and its runtime guidance. Existing
project-specific CRT choices remain intact. The New+ and logger fixes
from #50899 are not reverted.

The commit order keeps the shutdown fix before Hybrid CRT is re-enabled.
Rebasing already reapplied the fix; it was not duplicated. The final
diff against the PR base contains six files. The Runner documentation,
new Runner verification profile, and manual shutdown-check script are
excluded.

Existing Windows session-ending skips for Settings and Quick Access are
unchanged. No settings schema, IPC contract, elevation policy, or
pipeline changes.

The initial diagnosis used matching PDBs on lingering installed
0.102.2883.0 processes and an isolated static/Hybrid CRT linkage
experiment. These support the root cause but do not replace runtime
validation.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-22 16:08:51 +08:00
2026-02-11 22:59:53 +01:00
2026-09-16 09:13:00 -07:00
2020-03-05 10:11:27 -08:00
2020-05-02 15:59:18 -07:00
2026-02-14 15:47:56 +08:00

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Window Hopper icon Window Hopper Workspaces icon Workspaces
ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

✨ What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

For v0.103, we're working on a new Awake flyout, improving Screen Ruler, and continuing to modernize more utilities with WinUI 3.

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Languages
C 39.9%
C# 31.3%
C++ 13.6%
JavaScript 12.5%
PowerShell 2.3%
Other 0.3%