Fix a bug where the stream would not close if no data was received