main.lua may be busy or may have stopped responding

Yes, use ProcessSlicer.

(or OneShotIdleNotifier)