You could:
- Use an event structure in the loop in the popup VI and respond to the "Panel Close?" event. You would want this event to do the same thing as clicking either button - i.e., stop the subVI.
- Have the popup VI monitor its own front panel. When it sees it's no longer visible it can stop itself.
The first option is quite easy and doesn't require a continuous polling system like the second.