From 40aede0dfc4d84abb83debb931488aa80323456f Mon Sep 17 00:00:00 2001 From: David Alvarez Date: Sat, 23 May 2026 19:11:53 +0200 Subject: [PATCH] Fix Stop button: await ci.exit() so emulator process fully terminates before navigation, prevent stale audio --- frontend/src/pages/Play.svelte | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/Play.svelte b/frontend/src/pages/Play.svelte index 67a0b6b..4498024 100644 --- a/frontend/src/pages/Play.svelte +++ b/frontend/src/pages/Play.svelte @@ -64,14 +64,19 @@ booting = false; } - function stopEmulator() { - if (dosCI) { - try { dosCI.exit(); } catch (_) {} - dosCI = null; + async function stopEmulator() { + // Save reference then null it so the unmount cleanup doesn't double-try + const ci = dosCI; + dosCI = null; + + // Properly stop the emulator + if (ci) { + try { await ci.exit(); } catch (_) {} } if (dosContainer) { dosContainer.innerHTML = ""; } + running = false; push(`/game/${game.id}`); }