diff --git a/src/hub.js b/src/hub.js
index 01f21706a2830b6c25d893ccc2c17961ec0e0414..e9e8372004750e203848299409fc3b69936711df 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -173,6 +173,13 @@ const onReady = async () => {
     document.querySelector("a-scene").emit("username-changed", { username: displayName });
   };
 
+  const exitScene = () => {
+    hubChannel.disconnect();
+    const scene = document.querySelector("a-scene");
+    scene.renderer.animate(null); // Stop animation loop, TODO A-Frame should do this
+    document.body.removeChild(scene);
+  };
+
   const enterScene = async (mediaStream, enterInVR, janusRoomId) => {
     const scene = document.querySelector("a-scene");
     const playerRig = document.querySelector("#player-rig");
@@ -268,13 +275,6 @@ const onReady = async () => {
     }
   };
 
-  const exitScene = () => {
-    hubChannel.disconnect();
-    const scene = document.querySelector("a-scene");
-    scene.renderer.animate(null); // Stop animation loop, TODO A-Frame should do this
-    document.body.removeChild(scene);
-  };
-
   remountUI({ enterScene, exitScene });
 
   getAvailableVREntryTypes().then(availableVREntryTypes => {