How do I end the cycle?

My ex and I have been doing this run around circle with each other and I don’t know what to do. We dated for 1.5 years and for the past 4 years we’ve been friends with benefits but there’s definitely feelings there. We live in different city’s but not far and travel back and forth often. This past time everything was going great until I saw him texting some girl. I shut down and got sad and he comforted me, held my hand and cuddled me. He said cause he was single which is right but seeing it hurt so much.
I am now just sitting here hating myself for how I responded to the situation. Also thinking about how long he’s known her, where did they meet, etc.
Every few weeks this will happen. We’ll talk and everything is great (hooking up and hanging out) until something happens and it’s not. I get sad and then we don’t talk for a while and it starts again.
He said it’s hard that we live in different cities and that he does like me. I’m moving to the city he lives in in about 5 months.
How do I get out of this cycle? I don’t want to lose him but I’m hurting and I can’t keep doing this.
How do I un-fall out of love with someone?
How do I end the cycle?
Post Opinion