When, in the opinion of a majority of the members of any city or town council in any of the cities of the first or second class or any incorporated towns of this state, it shall be necessary and desirable to use the land which is or may be dedicated for the use of the general public as an alley through or across any part of any block in the city or town, upon which to build any public school, hospital, orphanage, or church building, or any addition to the buildings as may be built, it shall be lawful for the city or town council, by ordinance duly enacted, to vacate and close the alley, or any part thereof, thereby cancelling and rescinding the rights of the general public and the owners of real property abutting upon the alley to use the property as an alley. However, the procedure for vacating and closing an alley or any part thereof shall be as set out in this subchapter.