Index: abi/include/abi/shutdown.h
===================================================================
--- abi/include/abi/shutdown.h	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
+++ abi/include/abi/shutdown.h	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 Matthieu Riolo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup abi
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _ABI_SHUTDOWN_H_
+#define _ABI_SHUTDOWN_H_
+
+typedef enum {
+	SHUTDOWN_UNDEFINED = -1,
+	SHUTDOWN_CANCEL,
+	SHUTDOWN_REBOOT,
+	SHUTDOWN_HALT,
+} shutdown_mode_t;
+
+#endif
+
+/** @}
+ */
Index: abi/include/abi/syscall.h
===================================================================
--- abi/include/abi/syscall.h	(revision 40043e8d61ecdedef8f915d74b90ad59d8d19f85)
+++ abi/include/abi/syscall.h	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -102,4 +102,6 @@
 	SYS_DEBUG_CONSOLE,
 
+	SYS_SHUTDOWN,
+
 	SYS_KLOG,
 
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 40043e8d61ecdedef8f915d74b90ad59d8d19f85)
+++ kernel/generic/include/proc/thread.h	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -49,5 +49,4 @@
 #include <abi/proc/thread.h>
 #include <abi/sysinfo.h>
-#include <arch.h>
 
 #define THREAD              CURRENT->thread
Index: kernel/generic/include/shutdown.h
===================================================================
--- kernel/generic/include/shutdown.h	(revision 40043e8d61ecdedef8f915d74b90ad59d8d19f85)
+++ kernel/generic/include/shutdown.h	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -37,10 +37,15 @@
 
 #include <atomic.h>
+#include <typedefs.h>
+
+typedef struct thread thread_t;
 
 extern atomic_t haltstate;
+extern thread_t *shutdown_thread;
 
 extern void halt(void) __attribute__((noreturn));
 extern void reboot(void);
 extern void arch_reboot(void);
+extern sys_errno_t sys_shutdown(sysarg_t mode, sysarg_t delay, sysarg_t kconsole);
 
 #endif
Index: kernel/generic/src/main/shutdown.c
===================================================================
--- kernel/generic/src/main/shutdown.c	(revision 40043e8d61ecdedef8f915d74b90ad59d8d19f85)
+++ kernel/generic/src/main/shutdown.c	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -37,11 +37,15 @@
  */
 
+#include <abi/shutdown.h>
 #include <shutdown.h>
 #include <log.h>
 #include <cpu.h>
-#include <arch/asm.h>
-#include <arch.h>
 #include <console/kconsole.h>
-#include <proc/task.h>
+#include <console/console.h>
+#include <proc/thread.h>
+#include <stdlib.h>
+
+/* pointer to the thread for the shutdown process */
+thread_t *shutdown_thread = NULL;
 
 /** Halt flag */
@@ -81,4 +85,5 @@
 }
 
+/* Reboots the kernel */
 void reboot(void)
 {
@@ -93,4 +98,86 @@
 }
 
+/* argument structure for the shutdown thread */
+typedef struct {
+	sysarg_t mode;
+	sysarg_t delay;
+} sys_shutdown_arg_t;
+
+/* function for the shutdown thread */
+static void sys_shutdown_function(void *arguments)
+{
+	sys_shutdown_arg_t *arg = (sys_shutdown_arg_t *)arguments;
+
+	if (arg->delay != 0) {
+		thread_sleep(arg->delay);
+	}
+
+	if (thread_interrupted(THREAD)) {
+		free(arguments);
+		return;
+	}
+
+	if (arg->mode == SHUTDOWN_REBOOT) {
+		reboot();
+	} else {
+		halt();
+	}
+}
+
+/* system call handler for shutdown */
+sys_errno_t sys_shutdown(sysarg_t mode, sysarg_t delay, sysarg_t kconsole)
+{
+
+#if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE))
+	if (kconsole) {
+		grab_console();
+	}
+#endif
+
+	irq_spinlock_lock(&threads_lock, true);
+	thread_t *thread = atomic_load(&shutdown_thread);
+	if (thread != NULL) {
+		thread_interrupt(thread);
+		atomic_store(&shutdown_thread, NULL);
+	}
+	irq_spinlock_unlock(&threads_lock, true);
+
+	/* `cancel` or default has been called */
+	if (mode != SHUTDOWN_HALT && mode != SHUTDOWN_REBOOT) {
+		return EOK;
+	}
+
+	sys_shutdown_arg_t *arg = malloc(sizeof(sys_shutdown_arg_t));
+	if (arg == NULL) {
+		return ENOMEM;
+	}
+
+	//TODO: find a better way for accessing the kernel task
+	irq_spinlock_lock(&tasks_lock, true);
+	task_t *kernel_task = task_find_by_id(1);
+	irq_spinlock_unlock(&tasks_lock, true);
+
+	if (kernel_task == NULL) {
+		goto error;
+	}
+
+	arg->mode = mode;
+	arg->delay = delay;
+
+	thread = thread_create(sys_shutdown_function, arg, kernel_task, THREAD_FLAG_NONE, "shutdown");
+
+	if (thread == NULL) {
+		goto error;
+	}
+
+	thread_ready(thread);
+	atomic_store(&shutdown_thread, thread);
+	return EOK;
+
+error:
+	free(arg);
+	return ENOENT;
+}
+
 /** @}
  */
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision 40043e8d61ecdedef8f915d74b90ad59d8d19f85)
+++ kernel/generic/src/syscall/syscall.c	(revision 0116f21c8322ed5d0d54d2a20a217567036f889f)
@@ -192,4 +192,6 @@
 	[SYS_SYSINFO_GET_DATA] = (syshandler_t) sys_sysinfo_get_data,
 
+	[SYS_SHUTDOWN] = (syshandler_t) sys_shutdown,
+
 	/* Kernel console syscalls. */
 	[SYS_DEBUG_CONSOLE] = (syshandler_t) sys_debug_console,
