Pipe should be closed on error.