Wa `alaykum As-Salamu waRahmatullahi wa Barakatuh.
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
One should come out of i`tikaf when Ramadan ends. Ramadan ends when the sun sets on the night of `Eid.
Answering your question, we would like to cite the following fatwa published on www.islamqa.info:
The period of i`tikaf during the (last) ten nights of Ramadan ends when the sun sets on the last day of the month.
If he chooses to stay until he has prayed Fajr and then depart from his place of i`tikaf to the `Eid prayer, there is nothing wrong with that. Some of the scholars regarded that as recommended. (Fatawa al-Lajnah al-Da’imah, 10/441)
Imam Malik (may Allah be pleased with him) said that he saw that some of the scholars who had observed i`tikaf during the last ten nights of Ramadan did not go back to their families until they had attended the prayer of `Eid Al-Fitr with the people. Malik said: I heard that from the righteous people who have passed on, and this is the dearest to me of what I have heard about that.
Imam Al-Nawawi said:
“Al-Shafa`i and his companions said: Whoever would like to follow the example of the Prophet (peace and blessings of Allah be upon him) in observing i`tikaf during the last ten nights of Ramadan should enter the mosque before the sun sets on the night of the twenty-first, so that he will not miss any of it, and he should come out after the sun sets on the night of `Eid, whether the month is twenty-nine days or thirty. It is better for him to stay in the mosque on the night of `Eid so that he can offer the `Eid prayer there, or go out to the `Eid prayer-place if they pray `Eid there.
If he goes directly from i`tikaf to the `Eid prayer, it is recommended for him to do ghusl and make himself look good before going out, because this is one of the Sunnahs of `Eid.” (Al-Majmu`6/323)
Allah Almighty knows best.