It may well be that when science gives out, and is unable to answer questions of vital and fundamental interest, then religion will find a permanent place to step in and offer its own answers. This is a psychological point, not of great philosophical interest. For myself, I think religion has a deeper rationale - whether rationally adequate or not I offer no view here.
The trouble, when scientific explanations give out and fall short of answering 'why?' questions, is that religious explanations carry as many 'whys ?' in their train as science does.
If God created the universe and the laws or quantum probabilities on which it runs, why did God create the universe ? Could God have created just any universe, so one in which none of the recognised rules of logic or truths of mathematics applies ? If God is or was the First Cause, then how is God's own existence to be explained ? Did God create Godself ? If God is omnipotent, does that mean that God can do anything or only what it is possible to do ? And if only what is possible, why that limit ? If God forbids X, does God forbid X because it is wrong or is it wrong because God forbids it. (Plato's essential problem in different terms in the 'Euthyphro', of course.)
Anyone who thinks that this is a crack at religion will quite have misssed the point. Which is as I said at the start : that if you bring in religion to answer 'why ?' questions that science cannot answer, you will have opened the door to a whole new set of 'why ?' questions with which religion is itself beset. That this is so follows, for instance, from Aquinas' view that we not only do not but cannot know the essence of God : without knowledge of that essence we cannot answer the questions raised above.
This does not make science 'no better' than religion; equally it does not mean that religion is 'pointless' because in the end it leaves us with as many unanswered fundamental questions as science. I am trying to hold the balance even. In a different metaphor, I am just suggesting that if science leads us into a maze of unanswered questions, jumping over the hedge to religion will land us in another maze of questions ultimately as baffling.