I've written the code below in Prolog:
go :- write(">>"), read(X), process(X).
And do various things with process/1. To catch any unknown commands I've added:
process(Y) :- write("unknown command.\n"), go.
The problem is when exiting SWI-Prolog by closing the window before the normal end of the program, it gets into an infinite loop. I tried to search for what is SWI-Prolog calling when exiting like that but couldn't find it in order to include it in the code. Any help on that part or an alternative workaround would be really appreciated. Thanks in advance!