public void Close() { lock (mutex) { if (controllerState.Equals(CMSState.Quitting)) { return; } if (CMSLogger.CanCreateLogEvent(false, false, false, "CMSLogEndEvent")) { CMSLogEndEvent endEvent = new CMSLogEndEvent(); endEvent.SetDateTime(DateTime.Now); if (endEvent != null) { CMSLogger.SendLogEvent(endEvent); } } videoSource.StopSource(); controllerState = CMSState.Quitting; CMSTrackingSuite selectedSuite = model.SelectedSuite; if (selectedSuite != null) { selectedSuite.Clean(); } videoDisplay.Quit(); controlToggler.Stop(); CMSLogger.StopLogging(); } }