My son does this still and he is 9.
He wanders into closets and tries to pee. We just direct him to the toilet and back to bed. Usually peeing wakes him up after. Its kind of funny but I don want him peeing in my magazine rack so I make sure to guide him in the right direction.
Katie, mom to Olivia (97), Veda (98), Franky (2004), Wendy (2005), JoHannah (2007), Thea (2009) and Sunny (2011)