When it’s time to separate, you’ll be ready.
an nyeong hi ga se yo
Goodbye if you are the one staying and seeing someone leave.
an nyeong hi gye se yo
Goodbye if you are the one leaving.
If both parties are leaving, use the first one, 안녕히 가세요 (an nyeong hi ga se yo).