new function, UpdateBeforeExit()