@@ -246,6 +246,7 @@ func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt,
246246 done <- response{
247247 err: fmt.Errorf("failed to start agent processing stream: %w", err),
248248 }
249+ return
249250 }
250251 done <- response{
251252 result: result,
@@ -551,7 +552,7 @@ func (app *App) Shutdown() {
551552 var wg sync.WaitGroup
552553
553554 // Shared shutdown context for all timeout-bounded cleanup.
554− shutdownCtx, cancel := context.WithTimeout(app.globalCtx, 5*time.Second)
555+ shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(app.globalCtx), 5*time.Second)
555556 defer cancel()
556557
557558 // Send exit event