diff --git a/packages/opencode/src/cli/cmd/serve.ts b/packages/opencode/src/cli/cmd/serve.ts index 90c8a1d37af..5b2a867e99f 100644 --- a/packages/opencode/src/cli/cmd/serve.ts +++ b/packages/opencode/src/cli/cmd/serve.ts @@ -18,9 +18,12 @@ export const ServeCommand = cmd({ // kilocode_change start - graceful signal shutdown const abort = new AbortController() const shutdown = async () => { - await Instance.disposeAll() - await server.stop(true) - abort.abort() + try { + await Instance.disposeAll() + await server.stop(true) + } finally { + abort.abort() + } } process.on("SIGTERM", shutdown) process.on("SIGINT", shutdown)