In life, some people cross paths for a reason and when the reason goes away, they do too.
To lose people from your life is painful, but when you lose them in a painless way, you have to ask yourself, was it even worth spending so much time with them. The same amount of time could have been spent with someone who could hang around much longer. Prioritize the people in your life and spend as much time with them as you can. If they too leave you, at least you can live in the comfort that you are not the reason they leave.