Improve timeout logic with infinite prompts.