exit handling fixed