autotest: desktopui_ExitOnSupervisedUserCrash race fix

At the end of the desktopui_ExitOnSupervisedUserCrash, I was waiting
for a signal that the user session had ended while accidentally also
causing the UI to get torn down. This resulted in an unclean UI shutdown
that never sent the signal I wanted to see, so the test failed with
a timeout exception.

This change moves the listening for the session termination signal
so we properly wait for it before tearing down the UI.

BUG=chromium:462363
TEST=desktopui_ExitOnSupervisedUserCrash

Change-Id: Ied242e6fe711a78586a356666a73c75d71fb93ad
Previous-Reviewed-on: https://chromium-review.googlesource.com/254710
Trybot-Ready: Chris Masone <cmasone@chromium.org>
(cherry picked from commit 3e5df182dffdaee9c320bded819239e23d9eb16b)
Reviewed-on: https://chromium-review.googlesource.com/254810
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Tested-by: Yuly Novikov <ynovikov@chromium.org>
diff --git a/client/site_tests/desktopui_ExitOnSupervisedUserCrash/desktopui_ExitOnSupervisedUserCrash.py b/client/site_tests/desktopui_ExitOnSupervisedUserCrash/desktopui_ExitOnSupervisedUserCrash.py
index d8028c5..fae170d 100644
--- a/client/site_tests/desktopui_ExitOnSupervisedUserCrash/desktopui_ExitOnSupervisedUserCrash.py
+++ b/client/site_tests/desktopui_ExitOnSupervisedUserCrash/desktopui_ExitOnSupervisedUserCrash.py
@@ -57,10 +57,10 @@
                 nuke_browser_error = e
                 logging.warning('Browser may have crashed untimely: ', e)
 
-        try:
-            listener.wait_for_signals(desc='Session stopped.',
-                                      timeout=self._SESSION_STOP_TIMEOUT)
-        except utils.TimeoutError as actual_problem:
-            if nuke_browser_error is not None:
-                actual_problem = nuke_browser_error
-            raise error.TestFail(actual_problem)
+            try:
+                listener.wait_for_signals(desc='Session stopped.',
+                                          timeout=self._SESSION_STOP_TIMEOUT)
+            except utils.TimeoutError as actual_problem:
+                if nuke_browser_error is not None:
+                    actual_problem = nuke_browser_error
+                raise error.TestFail(actual_problem)