The Last Traded Price (LTP) is the price of the most recent trade. The exchange's official closing price isn't that last trade, though — it's a computed value: for most stocks, a weighted average of trades in the final part of the session; and for stocks that have F&O contracts, a Closing Auction Session (CAS) price. Because it's an average or auction price rather than the final tick, it can differ from the LTP you saw at the close.
This is also why your P&L can shift after the market closes — see Why does my P&L change after 3:30 PM?, which sets out exactly how each closing price is calculated. For the auction itself, see What is the Closing Auction Session (CAS)?, and for the terms, What do LTP, ATP and volume mean?