Keep stirring, after around 10 minutes on low heat, the dough will leave the sides of the pan. This is the stage when you want to remove pan from heat.
You can check if the dough is done or not by taking a small piece from mixture, let it cool down a little and then roll it between your thumb and index finger. You should be able to make a non-sticky ball out of it.