As Philip suggested this is the only formal way.
Less formal ways areâŚ.
You would initiate with
Good night
I am off to bed
Night night
I am going to hit the sack ( you are not wishing a good night, but informing them you are going to bed, but it would be replied to.)
And can reply saying:
Good night
Sleep well
Sweet dreams
Sleep tight
Night night
Donât let the bedbugs bite