After a male urinates, he doesn't wipe like a female would. Instead he holds onto his genitalia and "shakes" it, so as to dry off.
He had to (shake it off) so he could put it in his pants.
*glancing around stupidly at your friends, miming the shaking off* "(SHAKE IT OFF)".
~(shake it off) can also be used as a dumb immature joke, as seen in example number 2~