ensure the stream gets drained