diff --git a/app.go b/app.go index c42b879..7892297 100644 --- a/app.go +++ b/app.go @@ -1193,8 +1193,15 @@ func (a *App) runShutdownTasks(ctx context.Context, steps []shutdownStep) { a.emitShutdownEvent("shutdown:update", steps) } a.emitShutdownEvent("shutdown:done", steps) - // Give the UI a moment to show the "done" state before we yank the - // window away. 600ms feels purposeful without being annoying. + // Cleanly tear down hardware links before quitting. Especially the CAT + // backend: a FlexRadio keeps our API client registered until it notices the + // TCP is gone, and just letting the process exit left the slot stale — the + // NEXT launch then spent ~30s retrying the connect before the radio freed it. + // cat.Stop() closes the socket with a proper FIN so the radio drops us at once. + if a.cat != nil { + a.cat.Stop() + } + a.closeRelayDrivers() // release FTDI/serial relay handles for the next launch time.Sleep(600 * time.Millisecond) wruntime.Quit(ctx) }