I've been wondering how the Stargate knows how many persons/objects are going to pass the gate.

Let me explain. Three members of a SG-team passes through the gate and the last one is coming after 10 - 20 seconds. But sometimes just one person walks throught the gate and as soon as he/she has passed the singularity, it goes *poof* and the gate shuts down. How the gate knows when to shut down?