The Soviet Union was crumbling. He may have sped up the process by keeping a military presense in Eastern Europe when people said it would cause a war. But, the Soviet Union had exhausted any hope of survival when they went into Afghanistan.
However, Reagan deserves a lot of credit for rebuilding the armed forces.