Force a Quit

I have an app that communicates with a robot. If the USB adapter gets unplugged it generates an error which brings up a message box, then it is supposed to QUIT.
Before the user can click on the message box, the same message pops up again, and again, and again. . . .

I use several timers and several threads in the app. Before I open the msgbox I turn off all timers and even kill the threads, but it doesn’t help.

I know I need to clean up the whole communications routine so it isn’t so complicated, but that would be a major rewrite!
Is there someway I can force the quit?

In the mean time, I will keep trying to figure out what is causing the repeats.

I turned off the serial port also so now I have control back.

Is there a specific way to detect when a USB is unplugged?

Have the code which shows the msgBox set a Boolean flag to true. Have that same code not show the msgBox if myFlag=True.