First, it's absolutely imperative you find out why they were in the wardrobe in the first place. Check for any traces of Turkish Delight, or signs they might have been in the presence of an interdimensional witch. If they merely claim to have been having tea with a goat-legged man, talking to beavers, or wandering around a forest, that's not as concerning. Of course, they might only have been looking for clothes, in which case you're going to look really goofy for asking those kinds of questions. Your mileage may vary.
Regardless of how things got to that point, compassion and caution are important. If the person was hiding in the wardrobe and felt comfortable coming out when you were around, that's a sign of trust. Whether they should have been in there in the first place, what they might be doing that would involve a wardrobe, or other such questions, are better addressed in a spirit of love and friendship. Right, wrong, or indifferent, you're not helping anyone by making fun of them or shaming them. In that sense, it's much the same as how to handle a friend who
comes out of the closet.
On the other hand, they might be popping out of the wardrobe in an effort to scare you. In which case, you could always check for two things. First, can they fit back in there? Second, can the door be locked from the outside?