StrictMode stacktrace since stream was not closed properly

When the device lost connectivity, a StrictMode error could be thrown since
the stream had not been closed.