I think it is totally normal to be terrified when facing this. My own mother is 83 and terminal with end stage heart failure. I thought with her being elderly she would be at peace with the idea of dying and she has indeed sometimes said she is ok with it. However lots and lots of times over the last few years she has been utterly terrified. What helps her is to imagine that she is going to be reunited with my dead dad in a better place. So rather than think of "leaving" she thinks about "going to" (the next place where my dad is and where she won't be ill anymore). I don't know if that is any help. Perhaps if you have lost someone that you loved even a dog you could think about "going to them" rather than "dying".
It may be too soon for you to find this helpful as you are likely in shock and as you say utterly terrified. Once it starts to sink in perhaps make a list of anything you want to do like update your will or see certain people or write letters. Then try to spend what time you have left doing things you find peaceful (for me that's beside the sea, where I realise the insignificance of all us human "ants").
Another thought that has helped me help my mum is telling her we are all going to die. Just on different days. No-one avoids it. We are all on the same road with the same end.
My mum has been given antidepressants and anti anxiety meds for people in this situation and I think they have helped her a bit too.
I'm so sorry for your news. You sound alot younger than my mum of course and I don't know if you are leaving children behind which must be agony.
Life is short and very unpredictable and everything can change frighteningly fast.
My mum has a friend who is religious and she believes this (life on earth now) is "hell" and the afterlife is the "reward" for after.
I am often surprised by the number of people who have passed through my life who did not reach old age (it almost seems common). My husbands brother died at 28 from a blood clot. My first serious boyfriend died at 50 from cancer. A friends late wife died at 36 from breast cancer. My sister in laws dad died young from a heart attack as did my uncle. None of this helps you of course but perhaps will make you feel less alone to realise many others have also gone through this.
I hope you manage to find peace xx