I think Spock was big enough to take some good-natured kidding.
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.
You are 100% right---the episodes where Kirk reminds us that he is still feeling the loss are far superior to the lousy joke enders like Galileo Seven and Friday's Child.
Also on the positive ledger side WNMHGB and Balance of Terror.