Local and semilocal density-functional approximations for the exchange-correlation energy fail badly in the zero-thickness limit of a quasi-two-dimensional electron gas, where the density variation is rapid almost everywhere. Here we show that a fully nonlocal fifth-rung functional, the inhomogeneous Singwi-Tosi-Land-Sjolander (STLS) approach, which employs both occupied and unoccupied Kohn-Sham orbitals, recovers the true two-dimensional STLS limit and appears to be remarkably accurate for any thickness of the slab (and thus for the dimensional crossover). We also show that this good behavior is only partly due to the use of the full exact exchange energy.