public override void OnStop() { Trace.TraceInformation("WorkerRole is stopping"); this.cancellationTokenSource.Cancel(); this.runCompleteEvent.WaitOne(); if (id == "1") { jobServer.Close(); } base.OnStop(); Trace.TraceInformation("WorkerRole has stopped"); }