The stranger, Mark Twain, utters the following at the end before he departs:
"Oh! hang Smiley and his afflicted cow!"
He states that he muttered these words "good-naturedly," which is patently ironic because the tone is obviously not good-natured. The phrase means having or showing a pleasant, kind, and friendly disposition, which is clearly not the case here. Twain's use of exclamation marks (very close to an expletive), and his statement that the "amicable Mr. wheeler" should "hang Smiley and his afflicted cow" is more of an imperative than a friendly "thank you" to him. The speaker is clearly annoyed by Mr. Wheeler's monotonous tale and does not wish to indulge him any further.
Secondly, the irony is situational. The stranger refuses to continue listening but has, for a long time, closely followed Mr. Wheeler's narration without once interrupting him. He allowed Mr. Wheeler to speak on and on and is now almost inexplicably irritated by Mr. Wheeler's enthusiasm to continue the story. It is ironic that he spent so much time listening only to suddenly refuse to continue doing so. If the story has really been as boring and annoying as he has suggested, why did he not stop Mr. Wheeler and excuse himself earlier?
It appears as if the stranger (Mark Twain) was somewhat mesmerized by Mr. Wheeler's storytelling and only realized that he was being fooled with when Mr. Wheeler was called to attend to some matter and stopped speaking. It is almost as if Twain, during that brief break, regained awareness and came to his senses. He seems to have realized, in that moment, that Mr. Wheeler has been wasting his time and that listening to him would not bring him any closer to the actual character he enquired about: the cherished boyhood companion of his friend, Mr. A. Ward, Reverend Leonidas W. Smiley.
The ending of this short story, which is actually said by Twain himself rather than an anonymous stranger, is ironic because it shows how Twain recognises he has been the victim of a "tall story" and that the story he--and we as readers--have heard is not true. The teller of this story has clearly been having a great deal of fun at Twain's expense, and this is understood by Twain in the final few lines, when "the sociable Wheeler" returns and once again launches straight into another narrative about Smiley and his cow. Note what Twain says as he leaves:
"Oh! hang Smiley and his afflicted cow!" I muttered, good-naturedly, and bidding the old gentleman good-day, I departed.
Twain says these words "good-naturedly," and it is important to remember that although his words may seem offensive, they are actually ironic based on Twain's own sense of frustration at having been "barricaded" in by Wheeler and forced to listen to his tale for so long. It is interesting that Twain at various points in this tale describes the story that Wheeler tells him to be monotonous and dull, and yet the opposite is clearly the truth. These parting words therefore need to be seen in the same spirit, as Twain takes the opportunity to head off and avoid anymore so called "interminable" tales.