Rule reminder
Context determines the right phrase: time of day → greeting; first meeting → Piacere; departing → farewell; asking wellbeing → Come stai/sta?; bad news → Mi dispiace; register (formal/informal) must match the situation.
You want to leave a party and say goodbye to everyone at once. What do you say?