You are a prisoner. The only way to escape

You are a prisoner. The only way to escape the prison is to walk down a very long hallway that takes 2 hours to get through. Guards come out of a door halfway down the hall every hour and take any prisoners walking out back to the prison and escort any visitors out of the prison. The guards cannot tell the difference between prisoners and visitors. How do you escape?

Walk for about an hour and when you see the guard door open turn the other way and walk towards the prison. They will think you are a visitor and escort you to freedom.