stop writing after EPIPE
Merge pull request #84 from ap/issue-83

Fix #83