Index: rkward/windows/rkwindowcatcher.cpp
===================================================================
--- rkward/windows/rkwindowcatcher.cpp	(Revision 2901)
+++ rkward/windows/rkwindowcatcher.cpp	(Arbeitskopie)
@@ -20,6 +20,7 @@
 #ifndef DISABLE_RKWINDOWCATCHER
 
 #include <qlayout.h>
+#include <qapplication.h>
 
 #include <kmessagebox.h>
 #include <klocale.h>
@@ -78,6 +79,16 @@
 	}
 }
 
+void RKWindowCatcher::killDevice (int device_number) {
+	RK_TRACE (MISC);
+
+	RKCaughtX11Window* window = RKCaughtX11Window::getWindow (device_number);
+	if (window) {
+		window->close (true);
+		QApplication::syncX ();
+	}
+}
+
 ///////////////////////////////// END RKWindowCatcher //////////////////////////////////
 /**************************************************************************************/
 //////////////////////////////// BEGIN RKCaughtX11Window //////////////////////////////
Index: rkward/windows/rkwindowcatcher.h
===================================================================
--- rkward/windows/rkwindowcatcher.h	(Revision 2901)
+++ rkward/windows/rkwindowcatcher.h	(Arbeitskopie)
@@ -71,6 +71,9 @@
 /** called from the R backend when the device history needs to be updated
 @param params the serialized parameters as supplied from R */
 	void updateHistory (QStringList params);
+/** Kill an R device
+@param device_number R device number of the device to kil */
+	void killDevice (int device_number);
 private:
 	int last_cur_device;
 };
Index: rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- rkward/rbackend/rpackages/rkward/R/internal_graphics.R	(Revision 2899)
+++ rkward/rbackend/rpackages/rkward/R/internal_graphics.R	(Arbeitskopie)
@@ -77,11 +77,6 @@
 formals (plot.new) <- formals (graphics::plot.new)
 .rk.plot.new.default <- graphics::plot.new
 
-# Wait time between two dev.off () calls for the renegade devices;
-# users can change it by calling the function
-.rk.renegade.devices.kill.time <- 0.1
-".rk.set.renegade.kill.time" <- function (x = 0.1) .rk.renegade.devices.kill.time <<- x
-
 "dev.off" <- function (which = dev.cur ())
 {
 	.is.inter <- dev.interactive ()
@@ -89,24 +84,16 @@
 		# Why use 'which'? There is a which ()!!
 		if (!(which %in% .rk.preview.devices)) rk.record.plot$onDelDevice (deviceId = which)
 		
-		ldevs.before <- dev.list ()
+		.rk.do.call ("killDevice", as.character (which))
 	}
+
+	ret <- eval (body (.rk.dev.off.default))
 	
-	eval (body (.rk.dev.off.default))
-	.ret.value <- .Last.value
-	
 	if (.is.inter) {
-		renegade.devices <- setdiff (dev.list (), ldevs.before)
-		if (!is.null (renegade.devices) && length (renegade.devices) > 0)
-			sapply (X = renegade.devices, 
-				FUN = function (x) {
-					# sleep! otherwise, sometimes, rkward is left w/ an empty device window
-					Sys.sleep (.rk.renegade.devices.kill.time)
-					.rk.dev.off.default (x)
-				})
 		rk.record.plot$fixDeviceLists ()
 	}
-	return (.ret.value)
+
+	return (ret)
 }
 formals (dev.off) <- formals (grDevices::dev.off)
 .rk.dev.off.default <- grDevices::dev.off
Index: rkward/rbackend/rinterface.cpp
===================================================================
--- rkward/rbackend/rinterface.cpp	(Revision 2899)
+++ rkward/rbackend/rinterface.cpp	(Arbeitskopie)
@@ -385,9 +385,13 @@
 			MUTEX_UNLOCK;
 		}
 	} else if (call == "updateDeviceHistory") {
-		if (request->call.count () >= 3) {
+		if (request->call.count () >= 2) {
 			window_catcher->updateHistory (request->call.mid (1));
 		}
+	} else if (call == "killDevice") {
+		if (request->call.count () >= 2) {
+			window_catcher->killDevice (request->call[1].toInt ());
+		}
 #endif // DISABLE_RKWINDOWCATCHER
 	} else if (call == "wdChange") {
 		RKWardMainWindow::getMain ()->updateCWD ();
