- Only call the "onExit" method if it exists.