Theists might use this phrase to suggest that atheists aren't sincere in their beliefs. When it's time to face the final curtain, vehement atheists will recant their beliefs and admit that a benevolent deity (or deities) exist...or so goes the line of reasoning. "There are no atheists in foxholes" is usually said with a humorous voice inflection.
Unfortunately for the newly-converted soldiers and the more seasoned theists trapped in such horrible situations, they soon find out that there are no gods in foxholes either.