We usually entertain in the evening and virtually everybody we entertain goes to bed earlier than we do, so it's very seldom a problem for us. The only time I needed someone to leave was when I was working long hours, so I just said I was sorry but had to get up in the morning so needed to turf them out so I could go to bed.
A friend of mine gets up for work much earlier than I get up so when I visit him I'm conscious he'll need me to leave earlier than I'd naturally think to leave. He's a close enough friend that he doesn't need any pretense, he'll just say "right, I'm throwing you out" albeit in a lighthearted way. Usually it's around the time I'm thinking it's time to leave.