As a Closeted Gay Muslim

From my understanding, it is illegal to engage in homosexual activities based on the Islamic teachings. Across the globe, it also seems illegal for Muslims to leave Islam. Gay people from Malaysia might be able to get married in non-Islamic countries, but their marriage will not be recognised when they return home. I know that some gay Muslims might struggle to accept their sexuality, considering the religious restrictions that come with this faith.