The Heidelberg Catechism: Lord's Day 31
83. Question: What are the keys of the kingdom of heaven?
Answer: The preaching of the holy gospel and church discipline. By these two the kingdom of heaven is opened to believers and closed to unbelievers.
 Matt. 16:19; John 20:21-23.
84. Question: How is the kingdom of heaven opened and closed by the preaching of the gospel?
Answer: According to the command of Christ, the kingdom of heaven is opened when it is proclaimed and
publicly testified to each and every believer that God has really forgiven all their sins for the sake of Christ's merits, as often as they by true faith accept the promise of the gospel. The kingdom of heaven is closed when it is proclaimed and testified to all unbelievers and hypocrites that the wrath of God and eternal condemnation rest on them as long as they do not repent. According to this testimony of the gospel, God will judge both in this life and in the life to come.
 Matt. 16:19; John 3:31-36; 20:21-23.
85. Question: How is the kingdom of heaven closed and opened by church discipline?
Answer: According to the command of Christ, people who call themselves Christians but show themselves to be unchristian in doctrine or life are first repeatedly admonished in a brotherly manner. If they do not give up their errors or wickedness, they are reported to the church, that is, to the elders. If they do not heed also their admonitions, they are forbidden the use of the sacraments, and they are excluded by the elders from the Christian congregation, and by God Himself from the kingdom of Christ. They are again received as members of Christ and of the church when they promise and show real amendment.
 Matt. 18:15-20; I Cor. 5:3-5; 11-13; II Thess. 3:14, 15.  Luke 15:20-24; II Cor. 2:6-11.
The Heidelberg Catechism
Lord's Day 1