Click the in-game walkthrough button, then go back the way you came. The gate that had you trapped is unlocked now, so you can walk straight through and finish the stage.