Had the same problem. The Free Great Person Pop Up don't work. I looked around for answers, but it seems that no one is able to narrow down the specific problem. I like Kirmz solution the best. Simply bypass the problem by changing the effect of Hagia Sophia so that you don't get the free great person to begin with. Problem solved... although I also agree with Thalassicus that the solution isn't optimal... But it gave me an idea. If you already go through the trouble of modding the Hagia Sophia, why not simply change it so that it gives you the great person you would have chosen in the game... So I did a little research (I haven't actually done any modding myself until the line below) and added the following lines to "Buildings.xml" :
<Buildings>
<Update>
<Set FreeGreatPeople="0"/>
<Where Type="BUILDING_HAGIA_SOPHIA"/>
</Update>
</Buildings>
<Building_FreeUnits>
<Row>
<BuildingType>BUILDING_HAGIA_SOPHIA</BuildingType>
<UnitType>UNIT_ARTIST</UnitType>
<NumUnits>1</NumUnits>
</Row>
</Building_FreeUnits>
I saved my game the turn before I completed the Hagia Sophia. Then I exited the game and added the lines above (I wanted a Great Artist). When I continued the Game, the Hagia Sophia now gave me a great artist instead of giving me a (stuck) choice of great person. Problem solved! If you wish another great person then simply replace "UNIT_ARTIST" with "UNIT_SCIENTIST", "UNIT_MERCHANT", "UNIT_ENGINEER" or "UNIT_GREAT_GENERAL"
Although I would rather find out what causes the problem and fix it, I would have to know a whole lot more about modding than I do presently. But the solution above will bypass the problem rather than forcing people to sacrifice anything of worth in the game.