Fixing issue where OnExit was used instead of OnException