diff --git a/tsgqc.m b/tsgqc.m
index df12f336b4f6114d8be5b2da0d3b8a59b6654473..19bd0d686b811b7bd94387272dabad547333b5b9 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -3758,10 +3758,15 @@ end
     printpreview(get(hPlotAxes(4),'parent'));
   end
 
+  % save the map as image file
+  % --------------------------
   function mapSaveAsCallback(src, evnt)
     [file, path] = uiputfile({'*.jpeg';'*.png';'*.epsc'});
-    saveas(get(hPlotAxes(4),'parent'), fullfile(path,file));
+    if file == 0
+      return
+    end
     fprintf(1, 'Save figure map as %s\n', fullfile(path,file));
+    saveas(get(hPlotAxes(4),'parent'), fullfile(path,file));
   end