Added a null check before trying to close the stream.
Fixed a bug where the streaming failed exception was set on the upload session even if the upload
was already terminated and therefore the session is null.