The real problem with the ending was the television-related need for it to be upbeat after four men just died. If Kirk is a realistic character, his happy-talk with Spock and McCoy is a total facade here. He has to explain his losses to the Admiralty and probably write letters to four next of kin.
"Obsession" is another offender in this regard. "City on the Edge," "Catspaw," and "A Private Little War" got it right.
The fact Kirk was presented as anguished over crew deaths at all was enough; he did not need to carry the weight of Starfleet burial / torpedo tubes on his shoulders by the close of every episode where a death occured. That's the problem with TV from the 90s-forward: too many walk around in a depressed funk--in nearly every episode--like one in serious need of the couch or the edge of a rooftop.