Everyone of us see calamities, hardships, and difficulties in our lives. We try to overcome and get rid of them to best of our ability utilizing all available resources.
Allah taala tells us that
(ظَہَرَ الۡفَسَادُ فِی الۡبَرِّ وَالۡبَحۡرِ بِمَا کَسَبَتۡ اَیۡدِی النَّاسِ لِیُذِیۡقَہُمۡ بَعۡضَ الَّذِیۡ عَمِلُوۡا لَعَلَّہُمۡ یَرۡجِعُوۡنَ )
[Surah Ar-Rum 41] Calamities have appeared on land and sea because of what the hands of the people have earned, so that He (Allah) makes them taste some of what they did, in order that they may return (to the right way).
My Shaikh Hazrat Maulana Jalil Ahmed Akhoon Sb damat barkatuham says there are only two sanctuaries for the believers where they can find refuge against those calamities and difficulties.
First sanctuary is practicing Taqwa or Piety. On every occasion, under all circumstances, when alone or in front of thousands, the person who refrains from what displeases Him surely finds light at the end of the tunnel.
( وَمَنۡ یَّتَّقِ اللّٰہَ یَجۡعَلۡ لَّہٗ مَخۡرَجًا ۙ )
[Surah At-Talaq 2] Whoever fears Allah, He brings forth a way out for him
Second sanctuary is the repentance or Istaghfar. No matter if a person is a habitual sinner or a pious person, repentance will no doubt help. My Shaikh Hazrat Maulana Hakim Muhammad Akhtar Sb RA used to say that while sinners repent on there sins, a religious person who is apparently pious should also repent on the deficiency of sincerity and selflessness. It is reported in a hadith
من لَزِمَ الاستغفار جعل الله له من كل ضِيقٍ مخرجًا، ومن كل هَمٍّ فرجًا، وَرَزَقَهُ من حيث لا يحتسب
The one who makes it mandatory to do repentance, Allah taala opens door for him in every difficult situation and He keeps him away from the sorrow and grief and provides sustenance from where he cannot think of it.
The above two treasures Piety as and Repentance are no doubt sanctuaries from calamities and difficulties. However, their far bigger advantage is that they create our friendship with our Lord and help us find Him in our hearts.