bug fix for exit