Fixed to stop when error occurred