fixes to custom exit function for prompts

Changed so that when using the exit function the exit function is
applied before the expression is evaluated to avoid unnecessary screen
output.