Also, if the airport is extremely busy, the airline cannot risk losing their slot by loitering around at the gate, so they will plan things with a bit of buffer - closing the doors 10, 15, even 20 minutes before departure, and closing the flight 45 minutes or more before departure.