fix crash at exit / add assert