S.T.
I would probably have made him leave the friend's house immediately -- so the consequences are immediate to the behavior.
I have also had success with my 5 year old focusing on the positive - when my son does what I want, I give him high fives, pick him up and hug him, sing him songs. Tell him ahead of time that he can expect a treat (a favorite song, a story, a lollipop, some small thing he likes -- for a lot of behaviors, I just promise 10 high-fives). And when he does what he should, really go over the top on praise. It may feel sort of strange, but it has really worked for me. I've been surprised to find it a more effective a tool than scolding and threats (and much more pleasant for both of us).