I have learned to identify and distance myself from toxic people. I have tried to converse with them, seeking common ground, but when their behavior becomes intolerable, I simply let them go.
It is not healthy to be constantly dealing with people who only seek to do harm, undermining our mental health. If someone doesn't make a sincere effort to recognize and change their toxic behavior, it's best to walk away as soon as possible.
In the past, I was not always the most mature person. Inexperience and bad days led me to be dismissive or indifferent toward other people. However, over time I have managed to change this attitude. I have learned to be more prudent and to control my emotions, recognizing that there are times when I need to be more understanding and empathetic.
It sounds like you've had experiences, learned from them and found better ways to move forward which, as you say, is maturity and wisdom. Many people do not find it so well don't for having the honesty enough to know change was required and ownership enough to make the changes.