Sahih Muslim, Book 54, Hadith 161 (Muslim 7307)

Ma'qil b. Yasar reported Allah's Apostle (ﷺ) as saying:

Worshiping during the period of widespread turmoil is like emigration towards me.