Close pipe properly.