The US killed two birds with two nukes: they prevented Japan from continuing their rampage and they prevented Russia from taking Japan.
"Japan invaded the northern parts of Sakhalin, and ruled the entire island from 1918 to 1925. Russia has held all of the island since seizing the Japanese portion in the final days of World War II in 1945, as well as all of the Kurils."
While this is coïncidentally true, and a benefit given the later situation with the Cold War, it should be noted that there is no documentation from that time period where the 'Russian threat' was taken into account when the decision to drop the bomb has made.
There was, in later years, speculation that this was one of the reasons, but there's no memos, telegraphs, or other documents to show it was the case.