update application terminate logic