diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index fd5167db4..55156df32 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -395,9 +395,14 @@ pub fn run() { event_handlers::handle_reopen(has_visible_windows).await; }); } - tauri::RunEvent::Exit => { + tauri::RunEvent::Exit => AsyncHandler::block_on(async { + // Windows session ending currently reaches Tao as WM_ENDSESSION and + // destroys the loop without a preventable ExitRequested event. + if !handle::Handle::global().is_exiting() { + feat::quit().await; + } logging!(info, Type::System, "Application exited"); - } + }), #[allow(unused_variables)] tauri::RunEvent::ExitRequested { api, code, .. } => { if module::lightweight::is_in_lightweight_mode() && !handle::Handle::global().is_exiting() { @@ -405,7 +410,7 @@ pub fn run() { } else if code.is_none() { api.prevent_exit(); if !handle::Handle::global().is_exiting() { - AsyncHandler::spawn(|| async { + AsyncHandler::block_on(async { feat::quit().await; }); }