05c4dd5076
Register process.once('beforeExit') in waitUntilExit() so TUI apps
that finish naturally (no explicit exit/unmount) clean up before the
event loop drains. Add stdout write barrier in resolveExit() to ensure
all output is flushed before settling the exit promise.
Update testing render helper to await the additional async tick
introduced by the write barrier so early-error detection still works.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>