Modified TLS code to handle disconnects a little cleaner.