fixed crash at exit