People die, you have to focus on the positives before that. Its inevitable, but their life isn't a waste because of it. Focus on making their last moments the best. Not worrying about them dying, its hard but eventually you'll learn to cope; getting some inside therapy ( I presume being in careers like that have something to help you ) would help I would believe.
I was an EMT for a few years and I transported many regular patients. Most were terminal but lived for years with thier condition. I would try and cheer them up or make thier time with me one of the bright spots of thier day. Eventually the day comes when they arent there anymore. I grieved for them but always tried to remeber I did everything I could to make them happy and comfortable when they were here. I found comfort in that. Also try and take a little something away from each interaction you have, that way they never really leave and live on as a part of you. Hope that helps a little.
Those moments come in that career field Im afraid but that ususally have councelors you can talk to. Theres no shame in it and they help! I went to one after a bad accident I was a responder to, help out big time!