Skip to content

fix: avoid delay when page.window.destroy() closes Windows apps#6428

Open
ndonkoHenri wants to merge 3 commits intorelease/v0.85.0from
fix-window-destroy
Open

fix: avoid delay when page.window.destroy() closes Windows apps#6428
ndonkoHenri wants to merge 3 commits intorelease/v0.85.0from
fix-window-destroy

Conversation

@ndonkoHenri
Copy link
Copy Markdown
Contributor

@ndonkoHenri ndonkoHenri commented Apr 18, 2026

Fixes a Windows-specific delay where page.window.destroy() could take several seconds to terminate when prevent_close was enabled. The Windows path now disables native close interception and calls windowManager.close() instead of windowManager.destroy(), matching the upstream workaround for the window_manager shutdown stall.

Resolves #5459

Test Code

https://flet.dev/docs/controls/page#app-exit-confirmation

Summary by Sourcery

Resolve a Windows-specific shutdown delay by changing how desktop window destruction is handled when closing apps.

Bug Fixes:

  • Prevent long delays when page.window.destroy() closes Windows desktop apps with prevent_close enabled by disabling close prevention and using a normal window close instead of destruction.

Documentation:

  • Document the Windows desktop shutdown delay fix in the changelog.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 18, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: e26022b
Status: ✅  Deploy successful!
Preview URL: https://8d8f99cb.flet-website-v2.pages.dev
Branch Preview URL: https://fix-window-destroy.flet-website-v2.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 18, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: e26022b
Status: ✅  Deploy successful!
Preview URL: https://776359dd.flet-examples.pages.dev
Branch Preview URL: https://fix-window-destroy.flet-examples.pages.dev

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses a Windows-specific shutdown stall when calling page.window.destroy() while prevent_close is enabled, aligning Flet’s behavior with the documented window_manager workaround.

Changes:

  • On Windows, destroyWindow() now disables preventClose (if set) and calls windowManager.close() instead of windowManager.destroy() to avoid the stall.
  • Added a root CHANGELOG.md entry documenting the Windows fix and referencing issue #5459.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/flet/lib/src/utils/desktop.dart Implements the Windows-specific workaround in destroyWindow() to prevent multi-second close delays.
CHANGELOG.md Documents the user-facing fix for Windows desktop app shutdown delays.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling page.window.destroy() will cause the window to freeze for a few seconds before it resumes operation.

2 participants