Given this paragraph about the Cold War, why did the Soviets pull out of their war in Afghanistan?

Context: After World War II, parts of Eastern and Central Europe, including East Germany and eastern parts of Austria were occupied by Red Army according to the Potsdam Conference. Dependent communist governments were installed in the Eastern Bloc satellite states. After becoming the world's second nuclear power, the Soviet Union established the Warsaw Pact alliance, and entered into a struggle for global dominance, known as the Cold War, with the rivaling United States and NATO. After Stalin's death in 1953 and a short period of collective rule, the new leader Nikita Khrushchev denounced Stalin and launched the policy of de-Stalinization, releasing many political prisoners from the Gulag labor camps. The general easement of repressive policies became known later as the Khrushchev Thaw. At the same time, Cold War tensions reached its peak when the two rivals clashed over the deployment of the United States Jupiter missiles in Turkey and Soviet missiles in Cuba.

In 1957, the Soviet Union launched the world's first artificial satellite, Sputnik 1, thus starting the Space Age. Russian cosmonaut Yuri Gagarin became the first human to orbit the Earth, aboard the Vostok 1 manned spacecraft on 12 April 1961. Following the ousting of Khrushchev in 1964, another period of collective rule ensued, until Leonid Brezhnev became the leader. The era of the 1970s and the early 1980s was later designated as the Era of Stagnation. The 1965 Kosygin reform aimed for partial decentralisation of the Soviet economy. In 1979, after a communist-led revolution in Afghanistan, Soviet forces invaded the country, ultimately starting the Soviet–Afghan War. In May 1988, the Soviets started to withdraw from Afghanistan, due to international opposition, persistent anti-Soviet guerrilla warfare, and a lack of support by Soviet citizens.

From 1985 onwards, the last Soviet leader Mikhail Gorbachev, who sought to enact liberal reforms in the Soviet system, introduced the policies of glasnost and perestroika in an attempt to end the period of economic stagnation and to democratise the government. This, however, led to the rise of strong nationalist and separatist movements across the country. Prior to 1991, the Soviet economy was the world's second-largest, but during its final years, it went into a crisis.

By 1991, economic and political turmoil began to boil over as the Baltic states chose to secede from the Soviet Union. On 17 March, a referendum was held, in which the vast majority of participating citizens voted in favour of changing the Soviet Union into a renewed federation. In June 1991, Boris Yeltsin became the first directly elected president in Russian history when he was elected president of the Russian SFSR. In August 1991, a coup d'état attempt by members of Gorbachev's government, directed against Gorbachev and aimed at preserving the Soviet Union, instead led to the end of the Communist Party of the Soviet Union. On 25 December 1991, following the dissolution of the Soviet Union, along with contemporary Russia, fourteen other post-Soviet states emerged.

Answer: The Soviets withdrew from the Soviet-Afghan War beginning in May 1988 due to international opposition, persistent anti-Soviet guerrilla warfare, and a lack of support by Soviet citizens.