diff --git a/src/main/kotlin/org/briarproject/briar/desktop/Main.kt b/src/main/kotlin/org/briarproject/briar/desktop/Main.kt
index 5b1f9a998c6f19ef555c3e95cc0f111f62b16cd2..8ce0d7b4eab7e7341bdd59f9e7d4ea243a11156f 100644
--- a/src/main/kotlin/org/briarproject/briar/desktop/Main.kt
+++ b/src/main/kotlin/org/briarproject/briar/desktop/Main.kt
@@ -65,7 +65,10 @@ private class Main : CliktCommand(
         BriarCoreEagerSingletons.Helper.injectEagerSingletons(app)
 
         application {
-            app.getBriarUi().start(this)
+            app.getBriarUi().start {
+                app.getBriarUi().stop()
+                exitApplication()
+            }
         }
     }
 
diff --git a/src/main/kotlin/org/briarproject/briar/desktop/ui/BriarUi.kt b/src/main/kotlin/org/briarproject/briar/desktop/ui/BriarUi.kt
index b2bbafbf3c5a4967bced65d401983f34db2bf44c..70ffee14b4374f0339cf097ab8b8e5a85d16f6d7 100644
--- a/src/main/kotlin/org/briarproject/briar/desktop/ui/BriarUi.kt
+++ b/src/main/kotlin/org/briarproject/briar/desktop/ui/BriarUi.kt
@@ -5,7 +5,6 @@ import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
-import androidx.compose.ui.window.ApplicationScope
 import androidx.compose.ui.window.Window
 import org.briarproject.bramble.api.account.AccountManager
 import org.briarproject.bramble.api.lifecycle.LifecycleManager
@@ -36,7 +35,7 @@ enum class Screen {
 interface BriarUi {
 
     @Composable
-    fun start(applicationScope: ApplicationScope)
+    fun start(onClose: () -> Unit)
 
     fun stop()
 }
@@ -70,7 +69,7 @@ constructor(
     }
 
     @Composable
-    override fun start(applicationScope: ApplicationScope) {
+    override fun start(onClose: () -> Unit) {
         val (isDark, setDark) = remember { mutableStateOf(true) }
         val title = i18n("main.title")
         var screenState by remember {
@@ -89,7 +88,7 @@ constructor(
         }
         Window(
             title = title,
-            onCloseRequest = { stop(); applicationScope.exitApplication() },
+            onCloseRequest = onClose,
         ) {
             window.minimumSize = Dimension(800, 600)
             BriarTheme(isDarkTheme = isDark) {
diff --git a/src/test/kotlin/org/briarproject/briar/desktop/RunWithTemporaryAccount.kt b/src/test/kotlin/org/briarproject/briar/desktop/RunWithTemporaryAccount.kt
index dd669a4e72eaa301ef6fbe5dfcfe0800444ad112..16ec7364f8661e3a70fd8cb6dd313eb2eae86860 100644
--- a/src/test/kotlin/org/briarproject/briar/desktop/RunWithTemporaryAccount.kt
+++ b/src/test/kotlin/org/briarproject/briar/desktop/RunWithTemporaryAccount.kt
@@ -54,7 +54,10 @@ internal class RunWithTemporaryAccount(val customization: BriarDesktopTestApp.()
         Thread.sleep(1000)
 
         application {
-            app.getBriarUi().start(this)
+            app.getBriarUi().start {
+                app.getBriarUi().stop()
+                exitApplication()
+            }
         }
     }
 }
diff --git a/src/test/kotlin/org/briarproject/briar/desktop/TestUtils.kt b/src/test/kotlin/org/briarproject/briar/desktop/TestUtils.kt
index 0bc9746ca81376963566acbd622e9fa95af70e7a..c241e8e7a0d9a5dc916b5b8f8b2e55abfafe3fa8 100644
--- a/src/test/kotlin/org/briarproject/briar/desktop/TestUtils.kt
+++ b/src/test/kotlin/org/briarproject/briar/desktop/TestUtils.kt
@@ -18,5 +18,4 @@ object TestUtils {
         FileUtils.setRWX(dataDir)
         return dataDir
     }
-
-}
\ No newline at end of file
+}
diff --git a/src/test/kotlin/org/briarproject/briar/desktop/TestWithTwoTemporaryAccounts.kt b/src/test/kotlin/org/briarproject/briar/desktop/TestWithTwoTemporaryAccounts.kt
index 5f852e12b53228081b7a3f4d0728ca91f71339f5..2252d9e0860f2ecf2b2ccb0e5ac9eff16a58d8ab 100644
--- a/src/test/kotlin/org/briarproject/briar/desktop/TestWithTwoTemporaryAccounts.kt
+++ b/src/test/kotlin/org/briarproject/briar/desktop/TestWithTwoTemporaryAccounts.kt
@@ -21,6 +21,8 @@ internal class TestWithTwoTemporaryAccounts() {
         private val LOG = Logger.getLogger(TestWithTwoTemporaryAccounts::class.java.name)
     }
 
+    private val apps = mutableListOf<BriarDesktopTestApp>()
+
     @OptIn(ExperimentalComposeUiApi::class)
     fun run() {
         LogManager.getLogManager().getLogger("").level = INFO
@@ -41,6 +43,8 @@ internal class TestWithTwoTemporaryAccounts() {
                 DesktopTestModule(dataDir.toFile(), socksPort, controlPort)
             ).build()
 
+        apps.add(app)
+
         app.getShutdownManager().addShutdownHook {
             LOG.info("deleting temporary account at $dataDir")
             org.apache.commons.io.FileUtils.deleteDirectory(dataDir.toFile())
@@ -67,6 +71,11 @@ internal class TestWithTwoTemporaryAccounts() {
         // list yet, we need to wait a moment in order for that to finish (hopefully).
         Thread.sleep(1000)
 
-        app.getBriarUi().start(applicationScope)
+        app.getBriarUi().start {
+            apps.forEach {
+                it.getBriarUi().stop()
+            }
+            applicationScope.exitApplication()
+        }
     }
 }