no more crashes on shutdown

deletelater fixes this (threading and freeing, again..)
fix disconnection logic failing to allow shutdown after disconnect