Commands like exit that cause the shell to close should not produce errors on subsequent write or resize calls. Instead of throwing when the terminal is not running, silently drop the operation. Also wrap the raw PTY write/resize calls in try/catch to handle the race where the process exits between the status check and the call. Co-authored-by: Julius Marminge <[email protected]>