I have had this happen many times and United has always credited the mileage back to my account right away. I do however tell them at the gate to remember to credit the mileage back just to be sure.
------------------
UA, AA, Starwood, Hyatt and more.