Cancel connection before deallocation.