The problem with this situation is that the game doesn't define what "closer" really means, so you or your group will have to decide that for yourself. It could be either of the following (if you agree that only physical proximity is of question here):
- move the character so that the linear distance between them and your character decreases (so if the tile inbetween the two of you was a dead end, you would still move them there)
- move the character so that it will require less movement to get to them
(as indicated by Samthere in the comments, the Betrayal on House on the Hill FAQ reads: "[a monster] follows whatever path would lead it to the hero in the fewest moves", suggesting that this might be the intended way things work in this case as well)
Deciding between these options isn't all that trivial, as you could consider special tiles that allow extra movement, as well as special movement the traitor has (such as moving up the Coal Chute) or haunt-specific elements such as monsters or the traitor itself being able to move through walls.
Once you've come to a decision on that matter, you can decide whether you count unknown and therefore possible-but-npt-guaranteed pathways as the shortest direction. There are several factors I would consider in making this decision:
- if you allow unexplored rooms, you help the side that needs to find a room that's still in the stack (either because the adventure requires it, or because a character is trying to get out of the basement, for example)
- you could run into the situation where an unexplored room and the explored route both are equal distance to your traitor, and you need a way to handle that (whether the traitor decides, or you default to one of the options)
There is also the metagame statistics factor: In theory, you could end up at the point where there's no straight tile left in the pile, which you could theoretically know by keeping track of all straight tiles on the board and comparing the list to the total number of tiles in the stack. Therefore, it's possible that you reach the point where it's impossible that an unknown path is the shortest route, because if they do explore that room, it will certainly not provide a direct path to the traitor. The opposite is also true, where you could in theory know that there's only straight paths left in the pile, and therefore be certain that it's the shortest path without being certain which tile lies inbetween.
Now, by all means don't actually keep track of the tiles, but be aware of that possibility and it's implications on your question: There are situations where you could theoretically be certain, but in reality, you won't be. Personally, I would count this as a reason to never let unexplored rooms count as the shortest route, because in order to call them that, you would have to know they are.
Ultimately, though, it's a question that isn't directly answered by the rules and therefore needs to be determined by the playgroup. This is the only real answer anyone can give you prior to further errata being released...