Program stops when debugging stops

I’ve noticed something with my FezCerb. When I run my program without the debugger attached, the device stops responding. If I stop debugging the device stops responding. I have to power cycle it to get it back and even then sometimes it still doesn’t respond. It’s become sort of a hit or miss.

Now I know it’s the program not the device; because other test programs seem to work just fine. The program itself is pretty big ~2600 lines and there are multiple threads running in it. I’ve tried hard to ensure there are no long running tight loops in the program, however either I can’t find the problem or something else is wrong. I’ve check to see if the device is running out of memory; it is not.

What else could be wrong? Pursuant to this I will have to rewrite the program to be better, however I do not want to write in the same mistake into the new program. Any experiences with similar problems will help.