Each day the exchange publishes a settlement price that determines mark-to-market gains and losses and margin requirements. At expiry a contract settles either in cash (index futures, based on a special opening quotation) or by physical delivery (oil, gold, grains).
Retail traders almost never take delivery; brokers force a roll or liquidation before first-notice-day.
Example: ES September expires on the third Friday. Positions still open are cash-settled against the index's special opening price that morning; no shares change hands.
Related: mark-to-market, first-notice-day, roll, contract-month