Update closed flag

Update closed flag even if the stream is not initialized.
This to prevent the thread from running indefinitely, for example when
it’s sleeping and waiting to reconnect after am initial HTTP error.