Index: uspace/app/terminal/main.c
===================================================================
--- uspace/app/terminal/main.c	(revision 7b1131526b943ccb8250c1783bc3e4aca1a8246f)
+++ uspace/app/terminal/main.c	(revision ce862acf88a70a5985b57b43c19b2c0592970dbd)
@@ -33,7 +33,6 @@
  */
 
+#include <ui/ui.h>
 #include <stdio.h>
-#include <task.h>
-#include <ui/ui.h>
 #include "terminal.h"
 
@@ -98,6 +97,7 @@
 		return 1;
 
-	task_retval(0);
-	async_manager();
+	ui_run(terminal->ui);
+
+	terminal_destroy(terminal);
 	return 0;
 }
Index: uspace/app/terminal/terminal.c
===================================================================
--- uspace/app/terminal/terminal.c	(revision 7b1131526b943ccb8250c1783bc3e4aca1a8246f)
+++ uspace/app/terminal/terminal.c	(revision ce862acf88a70a5985b57b43c19b2c0592970dbd)
@@ -41,4 +41,5 @@
 #include <fbfont/font-8x16.h>
 #include <io/chargrid.h>
+#include <fibril.h>
 #include <gfx/bitmap.h>
 #include <gfx/context.h>
@@ -128,4 +129,6 @@
 };
 
+static errno_t terminal_wait_fibril(void *);
+
 static terminal_t *srv_to_terminal(con_srv_t *srv)
 {
@@ -133,7 +136,7 @@
 }
 
-static void getterm(const char *svc, const char *app)
-{
-	task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
+static errno_t getterm(task_wait_t *wait, const char *svc, const char *app)
+{
+	return task_spawnl(NULL, wait, APP_GETTERM, APP_GETTERM, svc,
 	    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
 }
@@ -804,8 +807,5 @@
 	terminal_t *term = (terminal_t *) arg;
 
-	(void) term;
-
-	// XXX This is not really a clean way of terminating
-	exit(0);
+	ui_quit(term->ui);
 }
 
@@ -1014,5 +1014,13 @@
 
 	list_append(&term->link, &terms);
-	getterm(vc, command);
+	rc = getterm(&term->wait, vc, command);
+	if (rc != EOK)
+		goto error;
+
+	term->wfid = fibril_create(terminal_wait_fibril, term);
+	if (term->wfid == 0)
+		goto error;
+
+	fibril_add_ready(term->wfid);
 
 	term->is_focused = true;
@@ -1040,4 +1048,19 @@
 }
 
+static errno_t terminal_wait_fibril(void *arg)
+{
+	terminal_t *term = (terminal_t *)arg;
+	task_exit_t texit;
+	int retval;
+
+	/*
+	 * XXX There is no way to break the sleep if the task does not
+	 * exit.
+	 */
+	(void) task_wait(&term->wait, &texit, &retval);
+	ui_quit(term->ui);
+	return EOK;
+}
+
 /** @}
  */
Index: uspace/app/terminal/terminal.h
===================================================================
--- uspace/app/terminal/terminal.h	(revision 7b1131526b943ccb8250c1783bc3e4aca1a8246f)
+++ uspace/app/terminal/terminal.h	(revision ce862acf88a70a5985b57b43c19b2c0592970dbd)
@@ -38,5 +38,7 @@
 #define TERMINAL_H
 
+#include <adt/prodcons.h>
 #include <errno.h>
+#include <fibril.h>
 #include <fibril_synch.h>
 #include <gfx/bitmap.h>
@@ -46,7 +48,7 @@
 #include <io/con_srv.h>
 #include <loc.h>
-#include <adt/prodcons.h>
 #include <stdatomic.h>
 #include <str.h>
+#include <task.h>
 #include <ui/ui.h>
 #include <ui/window.h>
@@ -91,4 +93,7 @@
 	service_id_t dsid;
 	con_srvs_t srvs;
+
+	task_wait_t wait;
+	fid_t wfid;
 } terminal_t;
 
