Take one’s leave of (someone)

To say goodbye to someone and leave (a formal old-fashioned expression).

The Princess took her leave of the Queen and left the room.