Fixed a couple of race conditions.

There were two race conditions that this fixes:  First, a
worker might disconnect between when the controller sends
a disconnect request to the server and when it receives
it.  Second, a controller might send a disconnect request
in between when the worker connects and when it is added
to the map of workers.