diff --git a/examples/exit.c b/examples/exit.c
new file mode 100644
index 0000000000000000000000000000000000000000..2a45b770b0d8a9576c9cb5e8c4cd932edd5418b9
--- /dev/null
+++ b/examples/exit.c
@@ -0,0 +1,14 @@
+/* halt.c
+
+   Simple program to test whether running a user program works.
+ 	
+   Just invokes a system call that shuts down the OS. */
+
+#include <syscall.h>
+
+int
+main (void)
+{
+  exit (5);
+  /* not reached */
+}
diff --git a/userprog/syscall_exit.c b/userprog/syscall_exit.c
index 4441a2715b4c4757fe6a9bb8ac41be89ca85c839..51b22083bc4002bcdb60a605a4fee48c3001be89 100644
--- a/userprog/syscall_exit.c
+++ b/userprog/syscall_exit.c
@@ -1,11 +1,15 @@
 #include "system_calls.h"
-#include "threads/thread.h"
+#include "threads/interrupt.h" // Dependency for intr_frame struct
+#include "threads/thread.h" // Dependency for thread struct
 
-void syscall_exit(struct intr_frame *status) {
+void syscall_exit(struct intr_frame *f) {
 	struct thread *current_thread;	// creates thread struct from thread.h
 	current_thread = thread_current(); // Sets current thread
 
-	current_thread->status = status; // Returning status to kernel
+	// pop off first int argument from interrupt frame
+	int exit_code = *((int*)f->esp + 1);
+	current_thread->exit_code = exit_code; // Returns exit code to kernel
+
 	thread_exit(); // Exiting current thread
-	return -1; // Returning -1 for success
-}
+	f->eax = -1; // Returning -1 for success
+}
\ No newline at end of file