Fixed bug: process never ends

The process didn't end in certain cases because of a logic bug.
Instead of looking if a certain exception was given, should have checked
if the exception occurs in short time intervals