'Treppenwitz' is an expression for the case when a joke comes to your mind too late, when you're already descending the staircase.

bill, you don't know how long I looked for a word/phrase for this concept, until discovering about a year ago the F. phrase l'esprit d'escalier; the wit of the staircase.