Why would smoke enter the cabin if the batteries are switched off before the APU flap closes?
Switching off the battery too soon interrupts the auto shutdown sequence.

In that sequence is an automatic de-oil procedure that is carried out. A de-oil valve introduces air into the oil pump to break the suction (reduce the drag) for the next start.


The air forces the oil back to the oil reservoir and out of the bearing chambers. If it doesn't the once warm oil will contract and add extra forces to overcome when it's cooled. The second benefit of the system is starting the APU in cold weather, with all the oil back in the reservoir, it can be uniformly heated before it is reintroduced into the lubrication system.


If that didn't happen, the next start will stress the oil system, a small leak may occur, which will burn and re-enter the cabin as burned oil (smoke).

If unsure about the last shutdown, the APU can be started and left running with no load whatsoever for 5 minutes to make sure it doesn't happen.



Also see this [somehow related] story on avherald.com. The mentioned Airbus publication link is broken, you can find it here.

Here's the APU shutdown sequence:


  
  At 95% speed, APU "AVAIL" lights go off.
  At 50% speed, the de-oil solenoid valve opens to decrease drag during the next start.
  At and below 7% speed:
  
  
  the de-oil solenoid closes,
  the APU fuel LP valve closes,
  the data memory module is updated,
  the air intake flap closes,
  the ECB de-energizes itself.
  
  
  
  (Airbus training manual.)




Do not use for flight.