This grammar pattern is used when a person has considered to do an action, but a another action happens which overlaps with the original planned action. It can be translated into ‘be about to…’. It attached to a verb stem.
● 가: 우리 같이 갈까요? / 나: 잘 됐네요. 저도 지금 막 나가려던 참이었어요.
● 가: 게임은 그만 하고 어서 자. / 나: 알았어요. 안 그래도 자려던 참이었어요.