Prevent uncaught broken pipe error

Closes #183.