There are no atheists in foxholes
"There are no atheists in foxholes" is a saying that means, roughly, that when things are bad, people tend to turn to God for help. While having little power as an argument for the existence of god, it is often used to undermine atheists, by asserting that despite all arguments, in a moment of crisis they too will seek a higher power. In a military context: 
Ernie Pyle, the iconic embedded World War II embedded journalist killed by Japanese machine gun fire in 1945, made famous the adage, "There are no atheists in foxholes."
He was making a point that it's better to be safe than sorry when your life is on the line - not letting the Devil get you cornered, he wrote, was the justification for a soldier who dug round foxholes. Atheists are a tiny minority anyway and there are even fewer in a war zone, Pyle felt. And he knew more soldiers than perhaps any journalist ever will.
Or more generally, adversity will make a non-believer turn to God: 
- "If you haven't yet been to the place where you didn't know where to turn, you'll get there. You will be in a hospital waiting room or a funeral home or a police station or at the scene of an accident or a doctor's office or bank or courtroom, and know (perhaps for the first time) that you don't have all the answers. [...] Go ahead, now, and get on speaking terms with God. He will be there for you later."
- Main Article: Emotions and religion
Although a hasty generalization, there is a kernel of truth in the claim "there are no atheists in foxholes". Research has found a variety of negative emotions increase religiosity, including socioeconomic problems, insecurity in relationships, bereavement, illness, personal crises, and thinking about mortality. 
Physiologists discovered that reminding a religious believers of death increases their professed religiosity. Perhaps surprisingly, it decreased their professed religiosity in non-believers. However, when implicit religiosity is measured, religiosity increases when reminded of death for both believers and non-believers.   A survey of WW2 veterans, 50 years after the conflict, found that those who had negative experiences of war were more religious.  
In Dialogues Concerning Natural Religion, David Hume argued that misery makes people more religious while contented people are less religious.
"There are no atheists in foxholes" is very weak argument and rarely used to argue for the existence of God..
In essence, the argument boils down to wishful thinking:
- I am not strong enough to handle all of life's problems on my own.
- Therefore, I want a higher power to help me.
- Therefore, that higher power exists.
While the first part is almost universally true, and the second is certainly understandable. However, the conclusion does not follow from the premises. Wishing for something does not make it true.
People in desperate situations take desperate measures, even if they only have a small chance of success. A person who has gone into cardiac arrest may want a doctor to use a defibrillator to restart their heart. But this does not mean that applying electrified paddles to people's chest is a good idea in general.
Suggesting atheists turn to God in a time of crisis could be considered a result of projection wherein the theist is uncomfortable with his own relationship with a god or religion as being a matter of comfort and not rationality.
Fear of an afterlife
- Main Article: Pascal's wager
When in extreme danger, the reminder of death may cause people to consider if there is an afterlife. They may choose to believe as an insurance policy in case they are killed. This reasoning is called Pascal's wager which considers the mere possibility of infinite punishment for not believing, justification enough to believe in God. However, people are not likely to be considering rational argumentation and philosophy when in extreme danger. Increased religiosity is more likely to be due to more fundamental psychological reasons.
Which side does God support?
Even if belief is strengthened by adverse circumstances, some individuals from all sides pray to God during war. It is difficult to conceive that God helps both sides of a conflict. Milton “Chris” Christian, a WW2 veteran said: 
- "They say there are no atheists in foxholes. But as we sat in those holes, praying that God would save us, I thought about the fact that the other side was doing the same thing. And then I wondered if God is just playing some kind of game with us. Pretty much I decided at that point there was no God"
Real-life military counterexamples
Even taken literally, the saying is not true. Many atheists have served in the military and have seen combat.
- Pat Tillman - an American Football player who joined the military and died fighting in Afghanistan.
- Military Association of Atheists and Freethinkers, who aim to provide a "community for atheists, humanists, and other nontheists in the military."
- ↑ 1.0 1.1 Science 2.0, Atheists In Foxholes? Not Many - And Less The More Soldiers Dislike War, May 24th 2013 
- ↑ Allen Webster, Where to Turn When There Is Nowhere to Turn 
- ↑ "Positive emotions as leading to religion and spirituality", Vassilis Saroglou, Coralie Buxant, Jonathan Tilquin, The Journal of Positive Psychology. 07/2008; 3:165-173. DOI:10.1080/17439760801998737
- ↑ Jonathan Jong, Jamin Halberstadt, Matthias Bluemke, Foxhole atheism, revisited: The effects of mortality salience on explicit and implicit religious belief, Journal of Experimental Social Psychology, Volume 48, Issue 5, September 2012, Pages 983-989, ISSN 0022-1031, http://dx.doi.org/10.1016/j.jesp.2012.03.005.
- ↑ 
- ↑ Brian Wansink, Craig S. Wansink, Are There Atheists in Foxholes? Combat Intensity and Religious Behavior, Journal of Religion and Health, 2013 Sep;52(3):768-79. doi: 10.1007/s10943-013-9733-y. 
- ↑ Carol Robidoux, An honorable man gets his medal, Union Leader Correspondent, Feb. 3, 2010