What happens to a plane that goes to / from an enclave when the surrounding country closes its airspace? When Pakistan closed its airspace, planes that had routes flying over Pakistan had to deviate around that country.

What would happen to planes en route to or from Lesotho, if South Africa closed its airspace?

Are the planes simply unable to leave or enter the country, or there is a law / regulation about this situation?
it would be no different than in case say China and Russia both closing their airspace for aircraft flying into and out of Mongolia. There'd be no way for aircraft to enter or leave that country.

Nothing special about being an enclave there.