That would really depend on the situation.
If you are asking the user for a command to enter, just uses read() or readln().
var
Answer: String;
...
write('What to do next: ');
readln(Answer);
if UpperCase(Answer) = 'CLOSE' then CleanUpAndCloseMyPrettyProgram;
..
If this doen't apply to youre situation, please try to describe the situation where you would need this.
Bart