//the application is closing, shut down all the servers and stuff private void DXWindow_Closing(object sender, CancelEventArgs e) { //save grid layout using (var file = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "GridLayout.xml")) { InstrumentsGrid.SerializeLayout(file); } //Dispose main viewmodel ViewModel.Dispose(); //then take down the client, the servers, and the brokers _client.Disconnect(); _client.Dispose(); }