Japan surrendered when Truman said they could keep the emporer.
Which was why Tojo came very close to killing the Emperor.
You might want to read the text of the surrender document:
“We hereby proclaim the unconditional surrender to the Allied Powers of the Japanese Imperial General Headquarters and of all Japanese Armed Forces and all Armed Forces under Japanese control wherever situated.”
Unconditional surrender. The decision to spare Hirohito was made after the war ended.