I am Not sure what you are asking. A program can be written to execute until the user asks it to end.
For Non-GUI programs, use a loop that continues looping until the user says to exit.
If a GUI...