From the time that Chillingworth moves into with Dimmesdale (at the suggestion of the townspeople) they are always together. Dimmesdale feels the doctor is just trying to take car of him, while we know Chillingworth is just trying to find out his dark secrets. Finally one night, filled with guilt, Dimmesdale climbs the scaffold. Though it is in the safety of night, he is standing on the same scaffold Hester and Pearl were on at the beginning of the book. Dimmesdale stands on the scaffold again at the end of the novel to confess that he is in fact Pearl's father. The scaffold is the only place where Dimmesdale can't reach him.
At the climax of the novel, Dimmesdale finally suceeds in overcoming his guilt and shame by standing on the scaffold and professing to the entire community what he has done. Even though this provides no physical escape, and one would expect would actually result in a restriction of freedom, it is the only way that Dimmesdale could have ever escaped Chillingsworth. He had made plans with Hester to find a physical escape by fleeing with Pearl to England, but we find out that Chillingsworth had learned of this and had made plans to board the ship with them. Dimmesdale can do nothing physical to escape Chillingsworth, because Chillingsworth's torment is not physical! The internal anguish that Dimmesdale feels as a result of his sins is tender to the evil intent of Chillingsworth, making him an easy target and a passive prey. He cannot run away, he cannot make his guilt go away, but he can admit his sins, even if it kills him. Ultimately, death and the release from his torment go hand in hand, and Chillingsworth cries "You have escaped me!" as Dimmesdale lies on the scaffold, finally hand in hand with Pearl, dying.
Telling the truth was the only way to free him. When Dimmesdale mounts the scaffold and confesses that he is the father of Pearl, he has "escaped" Dimmesdale. Dimmesdale no longer has a hold over him. Dimmesdale and Hester were going to leave on a ship to England, but Chillingworth had already planned on boarding the ship with them. He was going to follow them wherever they went, so telling the truth was Dimmesdale's only escape.