、「」。
As I was leaving the exam room, the doctor gave me a little wave and said 'bye-bye.'
Literal
Examination-room [object-を] leave moment, doctor [subject-が] 'bye-bye' [quotative-と] hand [object-を] waved [humbly-for-me-くださいました].
A warm patient-doctor moment. 間際 (まぎわ) is 'the very moment of, just before' — a temporal noun marking the instant just before an event. 診察室を出る間際 = 'the moment of leaving the exam room.' 手を振る is the collocation 'to wave one's hand.' 振ってくださいました combines ~てくれる (favor from someone) with its honorific variant くださる, in its polite past form くださいました — 'kindly waved [for me/at me].' くださる is used when the person doing the favor is someone to be respected, here the doctor. バイバイ is the loanword casual 'bye-bye,' which adds an unexpectedly warm/informal note from the doctor.