Deuteronomy 4:29-31 says:
29But there in these other lands you will look for the Lord your God. And if you look for him with all your heart and soul, you will find him.30When you are in trouble—when all those things happen to you—then you will come back to the Lord your God and obey him. 31The Lord your God is a merciful God! He will not leave you there. He will not destroy you completely. He will not forget the Agreement that he made with your ancestors. (Easy-to-Read Version)
King James Version: 29But if from thence thou shalt seek the LORD thy God, thou shalt find him, if thou seek him with all thy heart and with all thy soul. 30When thou art in tribulation, and all these things are come upon thee, even in the latter days, if thou turn to the LORD thy God, and shalt be obedient unto his voice; 31(For the LORD thy God is a merciful God;) he will not forsake thee, neither destroy thee, nor forget the covenant of thy fathers which he sware unto them.