From what I understand you can't leave unless you're excommunicated.
how does one go about doing that anyway?
Actually, in Spain many people are petitioning (and even suing) their dioceses to "annul" their baptisms and purge them from baptismal registries (some Spaniards - more than merely a few - consider the Church to be a highly disreputable organization, association with which harms their reputation in their own eyes). In some places, if I am not mistaken, the local bishops have all but given up and have issued some sort of letters confirming the "purge", but the bulk of the dioceses, not entirely unreasonably, consider the issue mildly ridiculous: baptism registry simply records the undisputed fact that your parents brought you to church and had the priest sprinkle some water on you: you can't "unsprinkle" it any more than you can have yourself "uncircumcized". In any case, if you don't take a communion, you aren't an active member of the Church, are you?