You just deal with it, as uncreative as that sounds. Its a painful experience, but it is an unfortunate part of being a pet owner: you spend as much time with them as possible when they’re around and then appreciate their life when they’re gone.
This mentality can extend to friends and family who have passed as well: cherish their presence and the memories you have of them.