There's a rumor floating around that Steve Carell was given a diferent script and wasn't expecting the song. He was staying in character until he heard Cut which would've come from Mindy Kaling (Kelly) since she wrote and directed this episode.
This wasn't just a good-bye from Andy, Jim, Pam, Ryan, etc. It was a good bye from Ed, John, Jenna, B.J,
Pretty awesome if it was true, but I haven't read anything that comfirms the rumor.