Fixed race caused by resetting connection manager in dispatcher before
threads currently running inside dispatcher are done.