It's a polite and formal way to say goodnight, often used when speaking to someone you respect or are not very close to.