Hello popup,
It would be usual to place the wait (or stop) instruction within the main loop of your program. When the external interrupt, or perhaps KBI occurs, processing of the ISR code should then immediately take place, and when completed, the operation will continue with the code immediately following the wait instruction.
You can then continue with other main loop operations before looping back prior to the wait instruction.
Regards,
Mac