cleaning up failed pipes properly, flushing error output to ensure it gets printed...