private void CloseAgent() { if (_starterThread != null) { AgentStarted = false; if (_client.IsConnected) { _client.Disconnect(null); } _starterThread.Abort(); _starterThread = null; } }