You can create buttons which the effect of causing the user to perceive that the program is not running, but it will actually be running in an idle mode.
Typically a state machine architecture is useful for this.
The entire program is inside a while loop. The program is configured to run when opened. A case structure or an event structure waits until the Run button is pressed. Then the code switches cases and runs your main code. The main code or the event structure also looks for the Stop button to be pressed. When it occurs, the shutdown portion of the code executes (close files, reset DAQ hardware to known states, ...) and then the program exits.
Lynn