Apostasy is the act of leaving a religion for another religion or for non-belief. Many religions have rules against apostasy and lay out specific punishments for apostates. People thinking of leaving their religion are often subjected to pressure, and in some cases abuse, murder  or legal execution. For instance, most Islamic scholars agree that the death penalty is the appropriate punishment for a male apostate, and that either imprisonment or death is appropriate for a female apostate. Other religions, such as Scientology and the Jehovah's Witnesses, urge their followers to shun apostates. These types of punishments are meant to keep believers faithful through fear.
- "In fact, unbelief is the only sin that cannot be forgiven. "
Some fundamentalists consider apostasy to be any significant disagreement with their views:
- "Among Muslim hard-liners, apostasy is thought to be not just conversion from Islam to another faith, but also committing actions that they believe are so against the faith that one is considered to have abandoned Islam. "
Apostasy in the Bible
The Old Testament says that apostates are to be killed:
"[If a] man or woman who does what is evil in the sight of the Lord your God, in transgressing his covenant, and has gone and served other gods and worshiped them, or the sun or the moon or any of the host of heaven, which I have forbidden, and it is told you and you hear of it, then you shall inquire diligently, and if it is true and certain that such an abomination has been done in Israel, then you shall bring out to your gates that man or woman who has done this evil thing, and you shall stone that man or woman to death with stones"
- — Deuteronomy 17:2-5 , emphasis added
The penalty of apostasy in the Catholic Church is automatic excommunication.  Excommunication is said to be Latae sententiae because the sentence is automatically imposed, if the apostasy is a wilful act carried out by an informed person.  An excommunicated person is forbidden to receive the sacraments (communion, weddings, etc) but is still allowed to attend church events. 
Between 2006 and 2009, act of actus formalis defectionis ab Ecclesia catholica was a way to inform the church of defection. It is unclear if this is required for an apostasy to be considered "formal", rather than "material". This act required notification of a competent ecclesiastical authority.  After 2009, changes to canon law abolished this procedure and inquiries to find a replacement have not been answered. 
Mormons consider other Christian denominations have deviated from the true faith and are therefore apostates. They consider Mormonism to be a revival of original Christianity. Mormons believe that without living prophets, mankind tends towards apostasy.
The traditional penalty for apostasy in Islam is death, although this is only upheld in a few countries. Saudi Arabia is suspected of carrying out executions for apostasy, although details are hard to verify in their secretive death penalty system.  Several other countries have the punishment in their penal codes, although it is not always applied, including Iran . The penalty is based on the Qur'an 4:89 :
- "They but wish that ye should reject Faith, as they do, and thus be on the same footing (as they): But take not friends from their ranks until they flee in the way of Allah (From what is forbidden). But if they turn renegades, seize them and slay them wherever ye find them; and (in any case) take no friends or helpers from their ranks;-"
Although the penalty is not upheld in most countries, there is significant support for the policy. It is the majority view of Muslims in Malaysia, Jordan, Palestinian territories, Egypt, Pakistan, Afghanistan.  Death for apostasy was supported by 36% of young (16-24 years old) UK Muslims.  A Nigerian man was confined to a hospital, supposedly due to mental illness after he announced his apostasy from Islam. 
Muslims are traditionally reluctant to accuse other self professed Muslims of apostasy because it opens themselves to the accusation as well:
“If a man says to his brother, ‘You are an infidel,’ ” the Prophet said, “then one of them is right.” If the accuser is wrong, he himself has committed apostasy by making a false accusation. The punishment for apostasy is death. 
Meriam Ibrahim converted from Islam to Christianity while living in Sudan. In 2014, she was arrested and threatened with death for committing apostasy. Following an international outcry, she was eventually allowed to move to the US with her family. 
Apostasy is sometimes used as a pretext to stifle political opponents. Samira Salih al-Nuaimi, a human rights lawyer and activist in Iraqi, was arrested, tortured and publicly executed based on accusations of apostasy. 
Raif Badawi, resident of Saudi Arabia, was sentenced to 5 years in prison, a large fine and 1000 lashes. His "crime" was to admit his atheism on facebook, support women's rights and creating a website called Saudi Liberal Network. He was accused of "encouraged sinfulness and ridiculing Islamic sanctities and spreading sedition and corrupting faith" 
Country specific issues
Several countries, especially ones with Christian state churches, have established procedures for having oneself taken off of the church's rolls. Some denominations also have documented procedures for doing so. While this can be a useful action in some situations, Christian churches can be left without following any procedure at all.
- Eroa kirkosta is a web site that allows one to resign from Finland's state churches, the Evangelical Lutheran Church of Finland, and the Finnish Orthodox Church. The site was established by the Tampereen Vapaa-ajattelijat (Freethinkers of Tampere).
- Ingen Kirkestat ("No church tax")
- Ut ur kyrkan ("Out of the church")
- Parents fatally whipped teen who wanted to quit church, New York court hears
- Code of Canon Law, Book 4, Part 2, Title 1, 1364 
- Colin B. Donovan, "Heresy, Schism and Apostasy" 
- Actus Formalis Defectionis Ab Ecclesia Catholica, 13 March 2006
- Church Continues to Block Formal Cessation of Membership, 20/07/2011 
- Ian Black, Amnesty condemns 'horror' of Saudi executions, The Guardian, 14 October 2008 
- Saeed Kamali Dehghan, Iranian Christian pastor released from jail, The Guardian, 8 September 2012 
- Policy exchange, Living apart together British Muslims and the paradox of multiculturalism, 29 January 2007 
- David Smith, Nigerian man is locked up after saying he is an atheist, The Guardian, 25 June 2014
- Leaving Your Religion, advice website on deconverting