fixed exit system call to return correct value