Avoid infinite loop when an exception occurs in command line mode