Rather than take the last print, which is easy to push, most exchanges define the settlement as a volume-weighted average across a short closing window. The band of prices in that window is the closing range, and the settlement-price is derived from it.
Using a window rather than a single trade makes banging-the-close expensive: to move the settlement you have to trade through the whole window, not just print one lot. It also means your position marks to a price that no single trade may have occurred at.
Example: crude settles on the volume-weighted average of trades between 14:28:00 and 14:30:00 New York time. If 8,000 contracts trade in that window between $78.10 and $78.22 with most volume at $78.18, the settlement lands near $78.17.
Related: settlement-price, daily-settlement, banging-the-close, trade-at-settlement, market-on-close