diff --git a/src/app/common/modals/settings.tsx b/src/app/common/modals/settings.tsx
index 9164acc2f..ce001b64f 100644
--- a/src/app/common/modals/settings.tsx
+++ b/src/app/common/modals/settings.tsx
@@ -440,8 +440,7 @@ class SessionSettingsModal extends React.Component<{}, {}> {
                 return;
             }
             let prtn = GlobalCommandRunner.sessionPurge(this.sessionId);
-            commandRtnHandler(prtn, this.errorMessage);
-            GlobalModel.modalsModel.popModal();
+            commandRtnHandler(prtn, this.errorMessage, () => GlobalModel.modalsModel.popModal());
         });
     }
 
diff --git a/src/util/util.ts b/src/util/util.ts
index ca7766fb4..252ba3c63 100644
--- a/src/util/util.ts
+++ b/src/util/util.ts
@@ -390,9 +390,12 @@ function getColorRGB(colorInput) {
     return computedColorStyle;
 }
 
-function commandRtnHandler(prtn: Promise<CommandRtnType>, errorMessage: OV<string>) {
+function commandRtnHandler(prtn: Promise<CommandRtnType>, errorMessage: OV<string>, onSuccess?: () => void) {
     prtn.then((crtn) => {
         if (crtn.success) {
+            if (onSuccess) {
+                onSuccess();
+            }
             return;
         }
         mobx.action(() => {