How is the closing price of a stock determined

How is the closing price of a stock finalized at market close?