Merge "Move the app exit handler to a new thread"