I'm implementing this algorithm in Java, I understand the algorithm as such, but I don't know when should I stop it. Is there any condition I can check in order to achieve so? I'm implementing a maze generator by the way.
You keep track of the remaining tiles. Say your maze has size (n,m) then set a counter to n*m - 1
and decrease it for any new tile visited and if 0 you're done.