fix crash on -hmd exit