First close all sessions, THEN start waiting for completion.

Remove the setContext call, from server.stop() as the methods inside
ServerSession are already handling the context switching.