From 44b92c542b2706bd30f77ccd98529fe14b69c099 Mon Sep 17 00:00:00 2001
From: Roxanne Skelly <roxanne@highfidelity.io>
Date: Thu, 28 Mar 2019 16:05:24 -0700
Subject: [PATCH] Case 20499 - Scripts that use AppUI don't call
 `that.onClosed()` if the script is restarted while the app is open

---
 scripts/modules/appUi.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/modules/appUi.js b/scripts/modules/appUi.js
index 3e8e0b1008..9771348377 100644
--- a/scripts/modules/appUi.js
+++ b/scripts/modules/appUi.js
@@ -353,10 +353,11 @@ function AppUi(properties) {
         // Close if necessary, clean up any remaining handlers, and remove the button.
         GlobalServices.myUsernameChanged.disconnect(restartNotificationPoll);
         GlobalServices.findableByChanged.disconnect(restartNotificationPoll);
+        that.tablet.screenChanged.disconnect(that.onScreenChanged);
         if (that.isOpen) {
             that.close();
+            that.onScreenChanged("", "");
         }
-        that.tablet.screenChanged.disconnect(that.onScreenChanged);
         if (that.button) {
             if (that.onClicked) {
                 that.button.clicked.disconnect(that.onClicked);