Improve error detection. Emit end and finish events on the stomp socket.