Yes. It forced a brutal war to end fast and likely spared millions from a mainland invasion and prolonged firebombing.
Japan was already collapsing and seeking surrender terms; the bomb wasn't the only path. Targeting civilians to make a point doesn't get a moral pass just because invasion was worse.