Index: sldump.cs
===================================================================
--- sldump.cs	(revision 38)
+++ sldump.cs	(working copy)
@@ -32,6 +32,7 @@
 {
 	class sldump
 	{
+        private static SecondLife client;
 		//
 		public static void DefaultHandler(Packet packet, Circuit circuit)
 		{
@@ -109,14 +110,18 @@
 			Console.Write(output);
 		}
 
+        public static void ExitHandler(object sender, ConsoleCancelEventArgs args)
+        {
+            Console.WriteLine("Logging out...");
+            client.Network.Logout();
+        }
+
 		/// <summary>
 		/// The main entry point for the application.
 		/// </summary>
 		[STAThread]
 		static void Main(string[] args)
 		{
-			SecondLife client;
-
 			if (args.Length == 0 || (args.Length < 3 && args[0] != "--protocol"))
 			{
 				Console.WriteLine("Usage: sldump [--printmap] [--decrypt] [inputfile] [outputfile] [--protocol] [firstname] " +
@@ -155,6 +160,10 @@
 				return;
 			}
 
+            // Logout on exit:
+            Console.TreatControlCAsInput = true;
+            Console.CancelKeyPress += new ConsoleCancelEventHandler(ExitHandler);
+
 			// Setup the callback
 			PacketCallback defaultCallback = new PacketCallback(DefaultHandler);
 			client.Network.UserCallbacks["Default"] = defaultCallback;
