Logically and theoretically, the last price traded should be the same as the closing price of a stock. However, the way we trade stocks and the markets we trade them on have undergone numerous innovations over the last decade. Thus a late-afternoon online search for a closing price or last quote might reveal conflicting results.
The last trade you see at the moment of the close may not truly be the last trade. With many stocks trading heavily at the close, a few minutes are required to process orders and determine which among them was the last trade. Depending on the exchange or quote service, these trades may be posted anywhere from 30 seconds to 30 minutes after the closing bell.
To make matters more perplexing, the closing price you see when you search for a quote online often is a consolidated quote. This quote is delivered from a system that pulls transactions from all stock exchanges and puts them into one data stream. In addition to a consolidated closing quote, many exchanges, like the NYSE and Nasdaq, offer an official last trade or closing price for trades on their exchanges. Hence, you get what appears to be differing last or closing prices.
Additionally, with the advent of after-hours trading, you may see a last price that differs greatly from the closing price because the last price in this instance represents the last transaction that occurred in ongoing after-hours trading. In another few moments, the stock may trade again and have a new last price, which may not match when compared against the unchanging closing price from normal trading hours.
(For related reading, see: Understanding the Ticker Tape.)