Potentially. It depends on where you live and who keeps the records. For example, if your records would be kept in public health services, or they would have a record of your health stuff for whatever reason (e.g. welfare), then the government may be able to disclose them if a request is made under the relevant act. Private and third-party providers will have their own policies which they'll abide by. People concerned in inheritance (the executor of a will, and in some places, people who may have a claim on your estate) can also make requests to some places for information related to their claim.
Your doctor does owe you confidentiality, so all of this will have to be legally managed, and it gets a lot less easy for them if it's unrelated to estate stuff, but compassionate grounds can also have this kind of thing disclosed, maybe. I don't know if they'd do it based on the effect it might have and judging your wishes.
Your best hope in situations like these is not the providers denying them, but that they are willing to let sleeping dogs lie.
Now here's some unsolicited advice that I give not because I'm telling you not to do this, but because your post is short and I don't know your relatives, so I'm just erring on the cautious side. Feel free to ignore it. Anyway, do you know if it would actually make it less hurtful? I'm sure there are many families it would for, but consider how people actually often react to terminal illnesses: hope and denial and trying everything. People often try to get you to try weird homeopathic stuff and are always looking for a miracle cure or telling you to hold on for one, etc. They have trouble accepting it and giving up, especially in the early stages when they're still in shock. It's possible that they may view a terminal illness exactly the same way as whatever your motives for ctb are. It may be just as painful because they will have viewed it as ceding all the chances you still had to get a second opinion or whatever (which is also how people view ctb). Only you can judge, unfortunately. I empathise with you wanting to minimise the pain to your loved ones.
And don't lie about anything that can have a genetic component because wanting to check that you're at risk for something / seeking genetic counselling is a very good reason in most people's eyes for wanting medical records.