Sorry, I don't have any example code, but this sounds like an application where you need a watchdog timer. Even if your code and the firmware is completely bug-free, you still can't expect it to run forever without crashing. A power fluctuation, intense EMI, or a cosmic ray could still cause a crash.
This is where watchdog timers come in. All mission critical embedded systems use them. The watchdog timer is continually counting down, and if the timer reaches zero, it will trigger a reboot. In the main loop of your code, you reset the watchdog timer, so that, while your code working properly, the timer will never reach zero.
Unfortunately, while the Oak chip definitely does have a watchdog timer, I'm not sure if the firmware currently lets the user access it. PeterF talked about it in
this post, so hopefully he might be able to dig into this a little further.