Hello, @Eharp. I appreciate your honesty and open heart in sharing this here. I wanted to be of any help I could by providing a few materials from the Buddha and his disciples.
Others here have given you great answers. Developing virtue and inner peace via non-harming, goodwill, and generosity are the essentials. It’s very helpful to reflect on any good you’ve done, are doing, and aspire to do. We often focus on our flaws, so it’s important to train the mind to recognize goodness and rejoice in it (which is itself a form of merit).
Likewise, the discourses also say that one of the benefits of cultivating mettā (loving-kindness) is that one does not ‘die confused’ and is instead clear. It also leads to a divine peaceful state, and a divine rebirth if practiced very deeply. Developing a firm sense of goodwill and kindness towards yourself and surroundings to nurture well-being and ease can brighten the mind a lot.
The Buddha’s teachings around death also greatly encourage people to develop the factors of stream-entry. That is, having experiential faith in the Buddha as an awakened guide, the Dhamma (reality expressed via his teachings), and the fourfold noble Sangha. This is followed by having strong sīla (virtue/ethics). It is based on an understanding of the four noble truths / non-self.
No matter the past, these factors can be aimed for and cultivated. If one does experience the fruition of stream-entry, you’ll be set, but even before then these are strong supports. Recollecting the Buddha/Dhamma/Sangha is the other main practice recommended alongside recollecting virtue. Thinking of the qualities of the Buddha/Dhamma/Sangha with faith and an aspiration to embody those qualities is a great practice and can be very powerful near death.
Passages recollecting the Triple Gem and the discourse on Mettā are recited extremely frequently by Buddhists. These are the ‘Tiratana Vandanā’ or ‘Itipiso’ chant, and the ‘Karanīya Metta Sutta.’ Even just chanting “namo tassa bhagavato arahato sammā sambuddhassa” is extremely common and could be helpful when afraid. It’s also mentioned in the suttas, so goes back a long time!
Chanting or reciting these relatively short passages would be a great way to establish a habit and potential refuge in more anxious moments. The suttas also talk of the benefit of memorizing the Dhamma, in that one may remember it in their next life and practice accordingly. In the very least, it will bring joy, faith, some sense of security, and build a karmic affinity with the Dhamma.
Finally, there’s the more profound Dhamma for one’s deathbed — letting go. Death is an extremely powerful time to realize impermanence and let go. It can be a time when people gain deep realization as reality finally dawns on them. Reflecting on the impermanent, fleeting nature of life. On the instability of our experience and the conditions we rely on. And being able to accept this condition without any resistance, not wanting to continue partaking in it again and again. This is letting go. There are some more detailed talks and instructions on this in the early discourses.
Here are useful teachings to read, reflect on, memorize, review, and enact. There are actually many, many more in the early canon. But these arw good starting place
AN 11.15 - Benefits of mettā
Snp 1.8 - Karaniya Metta Sutta
AN 6.10 - Recollections and meditations for noble disciples
MN 143 - Advice to Anathapindaka On His Deathbed
SN 22.1 - Advice to Nakula’s Father for aging
MN 120 - Rebirth by Intention
SN 55.3 - Concern for relatives at death and stream-entry
SN 55.24 - Reform on deathbed and stream-entry
MN 140 - Elements contemplation for being unshaken at death
SN 35.74 - Reflecting on impermanence at death
All the best!