It is possible for a priest to undergo laicization, or reduction to the lay state. The ordination itself cannot be undone, but the priest will then be allowed to live as a lay person. He will be forbidden to perform priestly duties unless for someone who is in danger of death.
The process takes several years, and the paperwork must go to Rome. Usually, the priest first leaves active ministry and has a regular job. During this time, he is still bound by celibacy. After a period of time, the priest can apply to be laicized. In order to marry, he must also be dispensed from the promise of celibacy (which is separate from laicization).
Certain conditions are often placed on the laicized priest prohibiting him from performing certain liturgical or catechetical roles. These are done to avoid scandal and confusion. I’m not sure of the details.
One priest told me that priests who leave usually leave because they stopped praying. In turn, we must also pray for our priests. While it may be allowed at times, it is always tragic when a priest leaves his ministry.