Additional safeties for AC::Live exceptions

Changed to not output anything to the stream unless the request was for html. Wrapped logging and closing the stream in begin/ensure, since the issue very well could have been in the socket itself.

Still need to determine whether an exception raised in this handler would cause the bug to occur or not. Also need to look at the on_error callback proposed in the pull request.