Starving the rest of the camera of CPU would make the camera shut down, not quit with a script error, so it's not clear why the sleeps would help.
If you can make a minimal example that reproduces the problem, that would be helpful. If that's not possible, attach the entire script and clearly describe the circumstances where the problem happens.
edit:
there should be an error message immediately preceding the the "PRESS SHUTTER TO CLOSE" message. This is generated in kbd.c wait_and_end() which should be called if lua_resume() returns an error.