Added safeExit