Fixed exit handling