Dropping two atomic weapons on Japan brought the war to an abrupt end and probably saved countless lives.
That the dropping of the atomic bombs on Japan was the factor that brought the war to its end is debatable.
Stalin had an agreement with the US that the USSR would engage with Japan 3 months after the defeat of the Germans. V-E day to the Soviets was May 9, 1945. 3 months after that was August 9, and on that day the Soviets began their invasion of Japanese-held Manchuria. (It also happened to be the day the second atomic bomb was dropped on Japan.) Japan was fighting a losing war against the US, and while I'm sure they didn't want any more atomic bombs dropped on them, they _certainly_ didn't want to fight both the US and the USSR. The USSR was as uncaring about casualties as the Japanese were, and they were holding a grudge from the Japanese defeat of Russia in 1905 in the war in the Russian Far East. The Japanese surrendered on August 14, 1945.