fix(util): properly handle exceptions from onPrepare and onExit