Fixed invalid reference in stopWithError function