Handle browser closing connection while sending data