What are the advantages of passing away in Medina?
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions and all those who follow his footsteps until the Last Day.
Medina is one of the holy lands of the Muslim ummah and we are commanded to visit it. The city of Medina is also the place where the Prophet PBUH migrated, of which it is the place chosen by Allah and Allah SWT commanded Rasullullah PBUH to emigrate to Medina. Medina is also the place beloved by the Prophet PBUH as stated in a hadith narrated from Aisyah R.Anha, where the Prophet PBUH said:
اللَّهُمَّ حَبِّبْ إلَيْنا المَدِينَةَ كَحُبِّنا مَكَّةَ أوْ أشَدَّ، اللَّهُمَّ بارِكْ لَنا في صاعِنا وفي مُدِّنا، وصَحِّحْها لَنا، وانْقُلْ حُمّاها إلى الجُحْفَةِ
“O God, make Medina as dear to us as Mecca, or more so, make it healthy, bless us in its sa’ and its mudd, and transfer its fever and put it in al-Juhfa.” 
There are evidences that state the favours and prioritization of dying in Medina. From Ibn Umar R.Anhuma, the Prophet PBUH said:
مَنْ اسْتَطَاعَ مِنْكُمْ أَنْ يَمُوتَ بِالْمَدِينَةِ فَلْيَفْعَلْ فَإِنِّي أَشْهَدُ لِمَنْ مَاتَ بِهَا
“Whoever among you can die in Al-Madinah, let him do so, for I will bear witness in favour of those who die there.” 
In the narration by Imam Ahmad, from Ibn Umar R.Anhuma, the Messenger PBUH said:
مَنْ اسْتَطَاعَ أَنْ يَمُوتَ بِالْمَدِينَةِ فَلْيَمُتْ بِهَا ؛ فَإِنِّي أَشْفَعُ لِمَنْ يَمُوتُ بِهَا
“Let him who can die in Medina, for I shall intercede for those who die in it.” 
The meaning of “die in Medina” (أَنْ يَمُوتَ بِالْمَدِينَةِ) means living and die there. The phrase “who can die there” (فَلْيَمُتْ بِهَا) means stay there until he dies and this is an encouragement to stay or reside there. 
Imam al-Tibi was cited to say: “The instruction to die in Medina is something beyond the capability of humans and it returns back to Allah SWT. However, the meaning of the hadith is the commandment to reside there and not leave the city. So that it will be the reason one gets to die there.” 
Saidina Umar RA also supplicated:
اللَّهُمَّ ارْزُقْنِي شَهَادَةً فِي سَبِيلِكَ وَاجْعَلْ مَوْتِي فِي بَلَدِ رَسُولِكَ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ
“O Allah! Grant me martyrdom in Your cause, and let my death be in the city of Your Apostle.” 
According to the supplication of Saidina Umar, Imam al-Nawawi held the opinion that supplicating to die in an honoured place is encouraged. 
According to the above evidences, those who die in Medina will attain favours in the hereafter by receiving the intercession of Rasullullah PBUH. Thus, what happened to Saidina Umar RA are two blessings:
First, his death as a martyr and in husnul khatimah for he is killed by the enemies of Allah while he was preparing to meet Him.
Second, Saidina Umar passed away in the city of Medina, the place where the Prophet promised his intercession. Hence, those who die in Medina will receive the intercession from the Prophet PBUH in the hereafter.
However, many of the companions of Rasullullah died outside of Medina. The reason is they see that there are matters more important which is dakwah to spread Islam worldwide. Furthermore, if all of them chose to just stay in Medina, surely, Islam would not have reached the whole world.
However, it is not wrong for us to supplicate so that our end is when we are in an honoured place especially in Medina a beloved place of Rasullullah PBUH. May Allah SWT grant us husnul khatimah in the city beloved by Rasullullah PBUH. Amin.
 Narrated by al-Bukhari (1889)
 Narrated by al-Tirmidzi (3917) and this is the wording, Ibnu Majah (3112) and Ahmad (5437)
 Narrated by Ahmad (5437) and this is the wording, al-Tirmizi (3917) and al-Baihaqi in Syu’ab al-Iman (4185)
 See Tuhfah al-Ahwazi, 10/286)
 (See Tuhfah al-Ahwadzi, 10/286)
 Narrated by al-Bukhari (1890)