Advances in U.S. military and technological development, the Soviet Union's costly and ultimately failed invasion of Afghanistan, and public discontent and economic weakness in communists countries led to the end of the Cold War and the collapse of the Soviet Union.