When restore is inside infinite loop, set restoreAtEpilog to true.