It was after the last commercial break. Barney was typing an entry for his blog onto his computer about everything that happened during the episode and the "lesson" he learned, which is how every episode of Doogie Howser ended, the screen looked the same and they even used the music from the show.
Another great thing about the episode was seeing 2 of the "final four" being from previous episodes, the chick Barney brought to the apartment Lily and Marshall were going to buy and when he impersonated Ted, by the way, tedmosbyisajerk.com is a real website like slapbetcountdown.com, pretty damn funny.