Fix use after free when resolv_cb() is called after connection has been closed