Deal with pipes closing while stopping. Fixes #270

The bug was that the SIGCHLD handler would fire after the ensure block
that closed the pipe. We can just ignore write errors on that pipe.