diff --git a/userprog/syscall.c b/userprog/syscall.c
index 210d7a8f536d405afada6e553ce469d5647a2a0e..f4b3381e10496f48986f20acbcc1fb4cb274d33c 100644
--- a/userprog/syscall.c
+++ b/userprog/syscall.c
@@ -69,7 +69,7 @@ syscall_handler (struct intr_frame *f UNUSED)
     break;
   default:
     printf ("WARNING: Invalid Syscall (%d)\n", syscall_number);
+    thread_exit ();
   }
   // TODO: remove this call to exit as we don't want all syscalls to make the thread exit
-  thread_exit ();
 }