To exit from the top level and return to the shell, either type
^D at the top level, or call the built-in predicate
halt/0
, or use the e (exit) command following a
^C4
interruption.
As noted above, ^D and ^C only works if running in a terminal or similar. If you are running inside SPIDER or GNU Emacs they have other ways to achieve the same effects.