To exit from Prolog, you can type halt at any prompt (followed by a period, of course).
If you find Prolog hanging at some point, and you are working on a standard Unix implementation, typing control-cshould produce something like the following message:
Prolog interruption (h for help)?You should reply with the character a, with or without a following period, followed by a carriage return. If this doesn't work, typing control-z should take you out of Prolog altogether.