If I sell a rental that was my primary residence until 10/1/18, must I complete the sale by 10/1/21 to claim a capital gains exemption? Close escrow on sale by then?

Just want to know how the 5 yr. window is calculated and what needs to be final by the 10/1/21 date