Answer:
The Soviet Union collapsed while their forces were still fighting in Afghanistan. The new government in Moscow made the decision to withdraw. I did not see it myself, but I was told that the Soviet commander in Afghanistan got out of his vehicle at the border and waited until he was the last one, and then he walked across. The Taliban, an Afghan anti-Soviet faction covertly supported by the US, quickly took advantage of the power vacuum and siezed control over most of the country.