When a Tower and the Approach Control closes, who takes over the airspace? and also what about When a Tower, within an Approach Control, closes, who takes over the airspace?
All airspace is ultimately owned by some Center (US: ARTCC, ICAO: ACC). Some is delegated to Approach facilities (US: TRACON), and Approach can sub-delegate part of their airspace to a Tower. And Center can delegate airspace directly to Towers without an overlying Approach.
If any facility closes, it’s associated airspace automatically reverts back to whoever had delegated it.
I work at an airport which closes at night. We have a control zone (class D), a TMA (also class D) and some surrounding airspace (class G/E). Tower and Approach control is provided locally during opening hours. When the airport closes, we call the area control centre responsible for the surrounding airspace, and they take over responsibility. In addition, the control zone and TMA actually seize to exist when local ATC is closed, so they both become class G airspace.
I also work at another airport where tower and approach control is provided locally, but two smaller airport have their own AFIS ("tower") below the TMA. When they close, they then call us and hand over the airspace to Approach. One of them becomes self-service when the AFIS is closed, so while Approach is technically responsible for the airspace, we will still advise traffic to switch to the local frequency to communicate directly with any other pilots in the area.
To add to StevenS answer, a Class D airport will usually revert to a Class E or G airspace after the tower closes. The hours and the subsequent airspace change will be noted in the US Chart Supplement. Most of the Class B airports that I know of generally do not close. Some busy Class C and D airports also do not close. Although, the FAA has reduced hours on many facilities due to reduced traffic.