As one longtime phrase goes, there are no atheists in a foxhole.
The interpretation is that when faced with death, a person wouldn’t want to be without the belief in a higher being or an afterlife. ASU physicist Lawrence Krauss took on a similar notion recently in The New Yorker. His piece is titled " The Fantasy of the Deathbed Conversion."