Send an event on ClientClosed, and factor out some cut-and-paste
Merge pull request #717 from typesafehub/wip/havocp-open-close-event

Send an event on ClientClosed, and factor out some cut-and-paste