that is because when the program exits the windows closes. you can add a deadline() like above, so the program will not exit before you enter. keystroke.
you can allow config debugging to not close the window.
Tools->Options->Debugging->Automatically close the console