Do not crash the main process when the stdout pipe is broken (#2372)