A quote from Orange is the New Black that seems pretty appropriate here.
Yoga Jones: Try to look at your experience here as a mandala, Chapman Perigrin. Work hard to make something as meaningful and beautiful as you can. And when your done, pack it in and know it was all temporary.
Make the best out of a bad situation until it's no longer a bad situation and you can move on and forget about it, maybe even be a better person from it.