 app/actions/window-commands.c |   38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/app/actions/window-commands.c b/app/actions/window-commands.c
index 6155313..05a10c8 100644
--- a/app/actions/window-commands.c
+++ b/app/actions/window-commands.c
@@ -25,9 +25,17 @@
 
 #include "actions-types.h"
 
+#include "config/gimpguiconfig.h"
+#include "core/gimp.h"
+#include "core/gimpimage.h"
+
 #include "widgets/gimpmessagebox.h"
 #include "widgets/gimpmessagedialog.h"
 
+#include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+#include "display/gimpimagewindow.h"
+
 #include "actions.h"
 #include "window-commands.h"
 
@@ -41,18 +49,34 @@ window_close_cmd_callback (GtkAction *action,
   GtkWidget *widget;
   return_if_no_widget (widget, data);
 
+  Gimp     *gimp;
+  return_if_no_gimp (gimp, data);
+
+  GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
+  GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
+  GimpGuiConfig *config;
+
+  config = GIMP_GUI_CONFIG (gimp->config);
+
   if (! gtk_widget_is_toplevel (widget))
     widget = gtk_widget_get_toplevel (widget);
 
   if (widget && gtk_widget_get_window (widget))
     {
-      GdkEvent *event = gdk_event_new (GDK_DELETE);
-
-      event->any.window     = g_object_ref (gtk_widget_get_window (widget));
-      event->any.send_event = TRUE;
-
-      gtk_main_do_event (event);
-      gdk_event_free (event);
+	  if (config->single_window_mode)
+	    {
+	      gimp_display_shell_close (shell, FALSE);
+	    }
+	  else
+	    {
+          GdkEvent *event = gdk_event_new (GDK_DELETE);
+
+          event->any.window     = g_object_ref (gtk_widget_get_window (widget));
+          event->any.send_event = TRUE;
+
+          gtk_main_do_event (event);
+          gdk_event_free (event);
+	    }
     }
 }
 
