there are many ways of saying goodbye, just as there are many of saying hello. It is important to use an expression of the appropriate tone and register. In the end, it's all up to your judgement but remember that using a very formal expression with someone who is your friend, as it may sound sarcastic.