public void Cleanup() { OpenVPNClient client = null; lock (m_clientSync) { if (m_client == null) { throw new Exception("client not initialized"); } client = m_client; m_client = null; } try { if (!client.Stop()) { throw new Exception("client stop failed"); } } finally { ClearContexts(); } }