Avoid blocking on the writer side by closing the reader when it's done.

This test case used to block at least on FreeBSD.