Do some dancing to ignore pipe closing errors.

Still needs to be used in other places.