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

Conflicts:
	ui/app/snap/SbtProtocol.scala