Handle broken pipe more elegantly