This explains it better than I can:
http://www.63xc.com/gregg/101_12.htm
That might be a lot of detail, I usually roll to a stop with my left foot forward and right foot back then cant the wheel 45 degrees to the left at the same moment I come to a stop. People say they are easier to do out of the saddle, but I have been learning them in the saddle because I'm stubborn and I think it's much more slick to do it that way.
Trackstanding through a whole light is a lot of fun, but I usually have to put a foot down about halfway through, 'cause I ain't so good yet.