diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html
index ecc295c9d5d1d8ff68999f45945aef2d4aff8f79..c66ca6a7b37eed919359607e8356a6f9fe211f17 100644
--- a/pd/nw/dialog_canvas.html
+++ b/pd/nw/dialog_canvas.html
@@ -753,10 +753,7 @@ function add_events(name) {
     // closing the Window
     gui.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-        //pdgui.pdsend(name + " menuclose 0");
-        //cancel();
-        pdgui.remove_dialogwin(pd_object_callback);
-        gui.Window.get().close(true);
+        cancel();
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_data.html b/pd/nw/dialog_data.html
index 9f7b1ba5a932bb059a7ec7352d7c3067da78d1fc..1fcaf0b16e631bb9e41d4f7a8a30a41bfd6c1b42 100644
--- a/pd/nw/dialog_data.html
+++ b/pd/nw/dialog_data.html
@@ -360,10 +360,7 @@ function add_events(name) {
     // closing the Window
     gui.Window.get().on("close", function () {
         // this needs to do whatever the "cancel" button does
-        //pdgui.pdsend(name, "menuclose 0");
-        //cancel();
-        pdgui.remove_dialogwin(pd_object_callback);
-        gui.Window.get().close(true);
+        cancel();
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_font.html b/pd/nw/dialog_font.html
index d4cddce417ba1dbf9cc8cb18a95048826e1c84fa..3cd6fd8cc9e2e3076e6386f1686cd948f6ac644b 100644
--- a/pd/nw/dialog_font.html
+++ b/pd/nw/dialog_font.html
@@ -177,10 +177,7 @@ function add_events(name) {
     // closing the Window
     gui.Window.get().on("close", function () {
         // this needs to do whatever the "cancel" button does
-        //pdgui.pdsend(name, "menuclose 0");
-        //cancel();
-        pdgui.remove_dialogwin(pd_object_callback);
-        gui.Window.get().close(true);
+        cancel();
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_gatom.html b/pd/nw/dialog_gatom.html
index 60e87cb26ded45afa8dae68e86120c86eb65ec4e..fd94947135020f51528ac32672a6c2876625636b 100644
--- a/pd/nw/dialog_gatom.html
+++ b/pd/nw/dialog_gatom.html
@@ -322,10 +322,7 @@ function add_events(name) {
     // closing the Window
     gui.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-        //pdgui.pdsend(name, "menuclose 0");
-        //cancel();
-        pdgui.remove_dialogwin(pd_object_callback);
-        gui.Window.get().close(true);
+        cancel(false);
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_iemgui.html b/pd/nw/dialog_iemgui.html
index 1a22fbe5035c2e16b93d4938d7ed22b2740bea3c..cf20d846b0f1a43bca2d5be78518ea2f03afe590 100644
--- a/pd/nw/dialog_iemgui.html
+++ b/pd/nw/dialog_iemgui.html
@@ -618,10 +618,7 @@ function add_events(name) {
     // closing the Window
     gui.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-        //pdgui.pdsend(name, "menuclose 0");
-        //cancel();
-        pdgui.remove_dialogwin(pd_object_callback);
-        gui.Window.get().close(true);
+        cancel(false);
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_prefs.html b/pd/nw/dialog_prefs.html
index 26e4082f6a543c9a2026b5e37af14dc2594ee838..e3fc34166754623dbce0f535ccdea8c9c1cf1ddf 100644
--- a/pd/nw/dialog_prefs.html
+++ b/pd/nw/dialog_prefs.html
@@ -787,9 +787,9 @@ function add_events(name) {
 
     // closing the Window
     gui.Window.get().on("close", function() {
-        // this needs to do whatever the "cancel" button does
         pdgui.remove_dialogwin(pd_object_callback);
         gui.Window.get().close(true);
+        //cancel();
     });
     pdgui.dialog_bindings(name);
 }
diff --git a/pd/nw/dialog_text.html b/pd/nw/dialog_text.html
index e995e469c0b5dd93cb36693a0314b1bf70897607..b5bc5d5b4780352f5c7ab961bf32c90b25abb53b 100644
--- a/pd/nw/dialog_text.html
+++ b/pd/nw/dialog_text.html
@@ -139,8 +139,8 @@ function translate_form() {
 
 function close_window() {
     pdgui.pdsend(pd_object_callback, "close");
-    pdgui.remove_dialogwin(pd_object_callback);
-    gui.Window.get().close(true);
+    //pdgui.remove_dialogwin(pd_object_callback);
+    //gui.Window.get().close(true);
 }
 
 function close_from_pd(signoff) {
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index f88d4c8b63e712d659c022503ac6cbc7ca14f482..24628ce80d7b9283fd1beb8d96d421551e47ba06 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -4258,7 +4258,7 @@ function gui_text_dialog_close_from_pd(did, signoff) {
 
 function gui_remove_gfxstub(did) {
     if (dialogwin[did] !== undefined && dialogwin[did] !== null) {
-        dialogwin[did].window.close(true);
+        dialogwin[did].close(true);
         dialogwin[did] = null;
     }
 }