Countless things happen in life. People come and go as they please. Things around you change, so quickly and differently that you cannot seem to get used to it. Sometimes, things happen and it is simply out of our control. Your valiant effort may end up completely futile but that's okay because whatever will be, will be.
I have come to learn that everything happens for a reason, be it good and bad and there is nothing else to do but to accept it. Accept it and move on. This applies to things like people leaving and failures, not things like an inability to do something, because that is something that you can change and improve.
Back to the point, It's difficult to let go of the emotional connection and relationship you once had with someone, how does a friendship so beautiful and real end and two people who were once everything to each other become mere strangers living separate lives. Quite unfair if you ask me but that's life and whatever will be, will be. There's no better way to explain it and it is best to know that you had done your best and it's time to move on now.
If there is entering, then there is exiting, so it's no doubt that people can enter you life then leave it. It's not easy knowing that anyone can simply leave you and that they are not here forever. However, I feel that you just have to cherish their current presence by treating them right and just embracing the fact that they exist in your life. I've come to accept the fact that no one stays forever and some things aren't meant to be salvaged. What's the point of holding onto a string that's bound to snap any moment, it'll hurt more to hold onto it then to let it go. Learn to be brave and accept things. And if fate allows, one day they may enter your life once again. Every person is a beautiful memory and lesson, not something to hold a grudge against.
It's okay to fail and it's okay for things to go wrong. Nothing has to be perfect and you don't have to be perfect. Things may not go your way all the time but you just have to move on. Lo Qué Será Será, whatever will be, will be.