Illustrative chart, drawn from constructed data for teaching.
What you are looking at
This catches people every single expiry, and it is entirely avoidable.
Settlement is not based on the last traded price. For index derivatives it is based on the weighted average price over the final half hour of the session. The exchange computes it after the close and publishes it.
The reason this matters: an option a fraction in the money on the last trade can settle out of the money, and the reverse. If your position's outcome depends on a margin that thin, you were never really in control of it — and the honest fix is to close the position rather than to hope the average lands your way.
On expiry day the question stops being "where is it going" and becomes "what will one specific number turn out to be". Those are very different questions to be exposed to.
This chart comes from the lesson Expiry day mechanics, where it sits alongside the rest of the idea.