diff -Naur kegs.0.91/src/xdriver.c kegs.0.91.patched//src/xdriver.c
--- kegs.0.91/src/xdriver.c	2004-12-06 19:42:47.000000000 -0500
+++ kegs.0.91.patched//src/xdriver.c	2011-01-27 04:28:42.000000000 -0500
@@ -57,6 +57,7 @@
 Display *g_display = 0;
 Visual	*g_vis = 0;
 Window g_a2_win;
+Atom g_wmdelete_atom;
 GC g_a2_winGC;
 XFontStruct *g_text_FontSt;
 Colormap g_a2_colormap = 0;
@@ -582,6 +583,9 @@
 		0, &my_winSizeHints, 0, &my_winClassHint);
 	XMapRaised(g_display, g_a2_win);
 
+	g_wmdelete_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);
+	XSetWMProtocols(g_display, g_a2_win, &g_wmdelete_atom, 1);
+
 	XSync(g_display, False);
 
 	g_a2_winGC = XCreateGC(g_display, g_a2_win, 0, (XGCValues *) 0);
@@ -1086,6 +1090,13 @@
 				(word32)ev.xcolormap.colormap,
 				ev.xcolormap.new, ev.xcolormap.state);
 			break;
+		case ClientMessage:
+			if(ev.xclient.data.l[0] == g_wmdelete_atom) {
+				x_auto_repeat_on(1);
+				XCloseDisplay(g_display);
+				exit(0);
+			}
+			break;
 		default:
 			printf("X event 0x%08x is unknown!\n",
 				ev.type);