If a person enters ihram for Hajj or ‘Umrah then something prevents him from reaching the Sacred House and completing his pilgrimage, if he had stipulated when entering ihram, “O Allaah, my exiting ihram will be where I am prevented from continuing,” then he will have exited ihram and will not have to do anything, but if he did not make this stipulation and then he is prevented from continuing, he should slaughter a sheep in the place where he was prevented from continuing, whether he was in the sanctuary or not, and he should give it to the poor people in that place or send it to the poor people of the sanctuary, then he should shave his head or cut his hair and exit ihram.
Allaah says (interpretation of the meaning):
“And perform properly (i.e. all the ceremonies according to the ways of Prophet Muhammad صلى الله عليه وسلم), the Hajj and ‘Umrah (i.e. the pilgrimage to Makkah) for Allaah. But if you are prevented (from completing them), sacrifice a Hady (animal, i.e. a sheep, a cow, or a camel) such as you can afford, and do not shave your heads until the Hady reaches the place of sacrifice”
Ibn Qudaamah (may Allaah have mercy upon him) said: The scholars are unanimously agreed that if the pilgrim in ihram is prevented from continuing by an enemy, be it mushrikeen or others, and they prevent him from reaching the Ka’bah and he cannot find a safe route, then he may exit ihram. Allaah has stated that in the verse, “But if you are prevented (from completing them), sacrifice a Hady (animal, i.e. a sheep, a cow, or a camel) such as you can afford”. And it is proven that the Prophet (blessings and peace of Allaah be upon him) ordered his Companions, on the day they were prevented from continuing (the ‘Umrah) at al-Hudaybiyah, to offer their sacrifices, shave their heads and exit ihraam. This applies whether the ihram is for Hajj or ‘Umrah or both, according to the opinion of our imam (Imam Ahmad), Abu Haneefah and al-Shaafa’i. … The one who exits ihram because he has been prevented from continuing has to offer the hadiy (sacrifice) according to the majority of scholars, because Allaah says, “But if you are prevented (from completing them), sacrifice a Hady (animal, i.e. a sheep, a cow, or a camel) such as you can afford.” Al-Shaafa’i said: There is no difference of opinion among the scholars of tafseer concerning the fact that this verse was revealed when they were prevented from continuing their ‘umrah at al-Hudaybiyah. End quote from al-Mughni, 3/172
Some scholars are of the view that if the one who is prevented from continuing cannot find a sacrificial animal then he may fast for 10 days, by analogy with the pilgrim who does tamattu’.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was of the view that if the one who is prevented from continuing cannot find a sacrificial animal, he does not have to fast, because Allaah did not mention fasting in the verse on being prevented from continuing one's pilgrimage.
And because the apparent of the situation of the Companions at the Treaty of al-Hudaybiyah was that they were poor and there is no report that the Prophet (blessings and peace of Allaah be upon him) commanded those who did not have sacrificial animals with them to fast for ten days.
See: al-Sharh al-Mumti’, 7/184, 185
Based on that, what you have to do now is to delegate someone to offer a sacrifice for you in Makkah to be distributed to the poor of the sanctuary, then shave your head or cut your hair and exit ihram.
You have to avoid all the things that are forbidden in ihram until your exiting ihram is complete.
Whatever you may have done during this period of things that are forbidden in ihram out of ignorance on your part, you do not have to do anything as a result.
If you cannot offer a sacrifice, then you should shave your head or cut your hair, and thus you will have exited ihram.
And Allaah knows best.