If the maze is not simply-connected (i.e. if the start or endpoints are in the center of the structure surrounded by passage loops, or the pathways cross over and under each other and such parts of the solution path are surrounded by passage loops), this method will not necessarily reach the goal.
Not necessarily all mazes:
https://en.m.wikipedia.org/wiki/Maze-solving_algorithm#Hand_On_Wall_Rule