Say it directly. Be polite and assertive. E.g., "I'm tired and I need you to leave now so that I can get some sleep." Use the broken record technique ( exact repetition) until they start to leave. Don't respond if they try to engage you in further conversation. Escort them to your door, gate or their car. Say a polite and (not overly) friendly good-bye.
If they query it sometime later, stand your ground.