d35d81b1a0
The `\x1b[?2004l` paste-OFF write at teardown was gated only on `stdout.isTTY`, which stays cached-truthy after a stream is destroy()ed/end()ed — so a teardown where stdout is already gone threw `ERR_STREAM_DESTROYED`. Route both `?2004l` sites (the setBracketedPasteMode disable branch and the dispose teardown backstop) through a `disableBracketedPaste()` helper that gates on `isTTY && !destroyed && !writableEnded`, matching Ink's `canWriteToStdout` (App.tsx:620/633). The live-stdout happy path is unchanged. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>