[verb (dictionary form)] + ところだった [verb (dictionary form)] + ところでした
ところだった after a dictionary-form verb says something nearly happened and then didn't: "almost", "nearly". It usually comes with もうすこし少しで, もうちょっとで or あやうく危うく, which say how close it came. The polite form is ところでした.
The thing that nearly happened is usually something bad, and the sentence carries relief.
The past tense sits on だった. The verb in front stays in the dictionary form, because the event never took place. たところだった is a different pattern: "had just done".
Without もう少しで or 危うく, ところだった can also mean you were on the point of doing something when something else came up. It is the past of ところだ, "about to".