--- lightdm-1.19.3/src/lightdm.c.1	2016-11-30 11:16:46.549436459 +0300
+++ lightdm-1.19.3/src/lightdm.c	2016-11-30 11:19:57.426432236 +0300
@@ -20,6 +20,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <sys/vt.h>
 
 #include "configuration.h"
 #include "display-manager.h"
@@ -174,9 +174,55 @@
     }
 }
 
+static int
+open_a_console (char *fnam)
+{
+        int fd;
+
+        fd = open (fnam, O_RDONLY | O_NOCTTY);
+        if (fd < 0 && errno == EACCES)
+                fd = open (fnam, O_WRONLY | O_NOCTTY);
+
+        if (fd < 0)
+                return -1;
+
+        if (! isatty(fd)) {
+                close (fd);
+                fd = -1;
+        }
+
+        return fd;
+}
+
+static void 
+switch_vt_console()
+{
+       int fd;
+
+        /* Switch to VT1 before going down. */
+        fd = open_a_console ("/dev/vt/active");
+        if (fd < 0) {
+                fd = open_a_console ("/dev/vt/0");
+        }
+
+        if (fd >= 0) {
+                int res;
+
+                res = ioctl (fd, VT_ACTIVATE, 1);
+
+                if (res != 0) {
+                        if (errno == ENOTSUP) {
+                                g_debug ("VT_ENABLE not supported, cannot switch to VT1");
+                        }
+                }
+        }
+}
+
 static void
 display_manager_stopped_cb (DisplayManager *display_manager)
 {
+    g_debug ("Switching VT to VT1 before going down");
+    switch_vt_console();
     g_debug ("Stopping daemon");
     g_main_loop_quit (loop);
 }