It doesn't happen all the time.
Here is the what FCOM, NORMAL PROCEDURE, SOP - SECURING THE AIRCRAFT says:
"wait until the APU flap is fully closed (about 2 min after the APU AVAIL light goes out), before switching off the batteries. Switching the batteries off before the APU flap is closed may cause smoke in the cabin during the next flight"