Coding- Killswitch Upon Disconnect

So me and my Mentor have run into a problem, there must of been some sort of line of bad coding or somesort. We made a T-Shirt cannon but during one of the events, the controller died and the robot kept spinning in circles even upon disconnect of the controller. How could someone stop all tasks and functions upon disconnect of the controller? Any Help would be appreciated. Thanks!

A couple of years ago we had a similar issue with our robot. The controller would disconnect from the robot and the robot would continue on with what ever it was doing. I think it was from electrostatic discharge. Is it possible to ground your robot to something? Also, if you are running on tiles or something similar can you ground those? I hope this helps.

I think this problem can probably be attributed to a factor other then coding, since it kept spinning even when you disconnected the controller (something it should not be doing!).

I don’t think you can run code upon disconnect, but you could assign a button on your controller to stopAllTasks();. It will stop all user tasks so should stop all your motors etc.

if(vexRT[Btn5U] == 1)

or something similar, I don’t have a copy of robotc with me to test