I think it's best to remember that GOOD NIGHT is like GOODBYE. Never say it when you meet someone, say it when you go.
GOOD EVENING is more flexible. You can use it when you meet, you can use it when you go.
If you are using it instead of (or with) goodbye then you have to decide when it is late enough to change good EVENING into good NIGHT. Only you can make that decision.
Actually, for me, if it is dark I habitually use GOOD NIGHT when I go, or they go. For me, good evening is the greeting, and good night is the goodbye. If it is dark!
If it was a really light summer evening, and 10pm (in Scotland it can be light at 11pm!), I probably would just say goodbye... then I wouldn't have to work out if it should be good evening or goodnight!
Other people habitually say "Good evening to you," as they go, even if it quite late.
There is no law to say you have to use one form or the other. It's personal choice and style.
Just don't say good night when you MEET!
And if confused on leaving, just say goodbye!