Typically you use "晚上好(wǎnshànghǎo)" to mean "Good evening." and use "晚安" when ending a conversation or when going to bed.
I know some speakers in Taiwan use "晚安" as greeting, and I am not sure if this is the case in mainland China.
Well... sometimes college students or even high school might have to stay at school at night, so they might say goodnight to their teachers. My Dad and Mom used to stay at their college classes at night.