If you want to exit XSB, issue the command halt. or simply type CTRL-d at the XSB prompt. To exit XSB while it is executing queries, strike CTRL-c a number of times.
halt.
CTRL-d
CTRL-c