Fix crash on socket close with nil delegate