Stop infinite loop bug #1765