I have nightmares and flashbacks about a past relationship

I was the one who ended it, and I'm so glad I did. It was the best decision I made in my life. But how do I stop the nightmares and flashbacks? It is creating a wall in my current relationship.