private void MainWindow_OnClosed(object sender, EventArgs e) { // Disconnect device after closing the Window. if ((_kCubeDCServo != null) && _kCubeDCServo.IsConnected) { _kCubeDCServo.Disconnect(true); } }