I think that no one should believe in God only because you were so afraid of death that you wished it were not the end. That belief in God is based on fear, not on faith.
When I was a believer, I received as a present a sonnet, originally in Spanish, whose translation I will share here. I think this is the real behavior a Christian should have. Believer because of the foxhole, no real believer.
If I were God, a Christian who could only do the right thing because he feels he will have a reward would not be better than the atheist who dies thinking there is no tomorrow.
To Christ Crucified
Heaven that you have promised me, my God,
Does not move me to love you.
Nor does hell so dreadful move me
To leave all that offends you.
You move me, Lord. It moves me to see you
Mocked, nailed to that cross.
It moves me to see your body so wounded.
Your dishonour moves me, and your death.
You move me to your love in such a way
That —even if there were no heaven— I would love you;
And —even if there were no hell— I would fear you.
You do not have to give to gain my love;
For —even if what I hope for becomes hopeless—
In the same way I love you, I would love you still.
—Translated by Stacy Shoop, 1996
(reproduced here with permission)