At least legally, the US had no “rights” over Afghanistan. Afghanistan was not a colony, territory or state of the US. The government was “free” to kick out the US whenever they wanted.
In practice, US foreign policy doesn't recognize international law and never really has.
The US could annex Afghanistan, and apart from the CCP doing a lot of complaining about it (primarily because they want access to Afghanistan's mineral wealth), nothing would happen.