O.L.
My DS used to do the same thing. He'd also poop every time he got put into a time-out (which didn't happen often, but he'd poop every single time). Smart little buggers, aren't they?
I told my son that I knew he was doing it to get to stay up and that I was going to start putting him in a diaper for sleep/quiet time. It took away the benefit of the added attention, and our son lost interest pretty quickly once we did that.
Good luck!
O.