Magical thinking is probably the single greatest threat to the longterm survival of the human race. I can think of no situation where it is not appropriate to criticise it. Furthermore, illness and death are exactly the times when human beings are most likely to abandon rationalism and cling to magic, so these are the very times when the fight is most important, and we shouldn't shy away from that just because it makes us uncomfortable to tell the dying their fairytales are untrue.
The only person you are trying to benefit when you are trying to convince the dying of atheism is yourself. We should let people live their final days believing whatever they want. Even as an atheist, its clear to me that the right thing to do is allow the dying to be happy and comfortable, however they want that. Furthermore, there are many, many threats to longterm survival, not just mysticism.