write error or by receiving SIGPIPE. This avoids leaving the tty in a mess. Probably addresses PR 30287.