Fix pkgmgr_client_free() in thread race condition