The third militant fled to one of the mosque 's minarets where he died in an exchange of gunfire with police .