finally {
// Wait a second for messages to arrive before we logout
try { Thread.sleep(1000); } catch( InterruptedException i) {}
Global.waitOnKeyboardHit("Success, hit a key to exit");
if (sender != null && sender.isConnected()) { sender.disconnect(new DisconnectQos(sender.getGlobal())); }
if (receiver != null && receiver.isConnected()) { receiver.disconnect(new DisconnectQos(receiver.getGlobal())); }
}
}