native-resource: Set res_ctx and mainloop to None after disconnect