I don't think you can really say the ending is tragic. The whole firing squad thing is just another of Mitty's fantasies.
I think it is kind of humorous in a bleak sort of way like the rest of the story is. I guess you can say it's tragic because Mitty is such a loser that he has to retreat into fantasy to have any sort of a feeling that he is worth something.
But in general, I find it more amusing. I guess I'm laughing at Mitty because he seems so pathetic.
While Walter Mitty is a pitiable character, he is yet one who rises from the ashes of his henpecked life with his imagination. So, there is something wrily humorous about him, yet heroic at the same time. To this day, when someone who is an unknown, ordinary, quiet and retreating, invents something or makes a success of his/her life, newcasters will call this rise to fame, "a real Walter Mitty Story."
So, at the end of "The Secret Life of Walter Mitty" the repressed Walter does fail at his attempts toward independence and respect as his wife dismisses his declaration, "Does it ever occur to you that I am sometimes thinking?" with "I am going to take your temperature when I get you home." However, as "that faint, fleeting smile plays about his lips," Walter, again in fantasy, succeeds in his dreams as he departs with his wife,
proud and disdainful, Walter Mitty the Undefeated, inscrutable to the last.