Correctly terminate download server on end of stream.