rewrote app exit sequence