; Call module destructors. This is also the _exit entry.
-_exit: sta ST ; Place return code into ST
+_exit: pha ; Save the return code
jsr donelib ; Run module destructors
; Restore system stuff
dex
bpl L2
+; Place the program return code into ST
+
+ pla
+ sta ST
+
; Reset changed vectors, back to basic
jmp RESTOR