Clear the stack after generating each program; avoid an infinite loop.