Sayyiduna Ibn Abbas (may Allah be pleased with them both) said concerning this saying of Allah Almighty, "Admit me with an entrance of truth and bring me out with an exit of truth" [Al-Isra: 80]: The Prophet (peace and blessings be upon him) stayed in Makkah for ten years; then this verse was revealed: "Say: My Lord! Admit me with an entrance of truth and bring me out with an exit of truth" [Al-Isra: 80], and so he (peace and blessings be upon him) emigrated to Madinah.
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 12564