Upvote:5
The airline can refuse transportation if you are not at the gate at the boarding time printed onto your boarding pass. They will close the gate after the announced boarding time when there no more passengers waiting next to the gate to be boarded (whatever event comes later). Sometimes they may decide to wait for connecting passengers coming with delayed inbound flights. But that's their choice!
Note that for a 9 o'clock flight, 8:40 is already very late. Boarding times of 45 minutes are quite common and 8:40 leaves only 20 minutes, which is already very tight, as there are ground handling procedures to be performed after everyone is seated. On international flights (and large planes), boarding often starts 60 minutes before departure. So since the boarding time is already tight for your flight, I wouldn't risk being late late for your flight.
The time to go through security and to your gate varies from 5 minutes to more than one hour, depending on the airport, the time of the day, and whether you will be invited to a secondary security check. So we can't give a good answer here.