Allah is an infinite source of wisdom, justice, compassion and grace, and a real believer should never lose hope or succumb to negative thoughts in difficult situations. Allah commands His followers to remain hopeful and to trust in His infinite power and mercy, even when facing difficult circumstances. Following this morality will lead to peace, tranquility and joy of expecting Allah's help and closeness, even in the most difficult of situations. Allah is the source of both blessings and difficulty, and He is the only one who can provide His guidance and help for any person. It is important to trust in Allah and to pray with hope and sincerity, as He will always create the best outcome for Muslims in this world and in the Hereafter.
The story of Prophet Musa (peace be upon him) is an example of how Allah can provide a way out of seemingly impossible situations.