What "should" you do can be interpreted to be a very different question than what is the outcome that is dictated by the general law of contracts.
The ultimate question a court would want answered is what was the parties' mutual intent regarding the deposit. In other words, what did the two of you specifically agree with respect to the deposit? Your posts suggest that there may have been no mutual agreement -- i.e., that the buyer's intent was that the deposit would be refundable and your intent was that it would not be. If there was no mutual intent, then there was no contract as it related to the deposit. You seem to be interpreting that to mean that you get a windfall, but that's not legally accurate.
It would appear that you did have a contract the terms of which were that you would sell the car to the buyer for $X. The buyer has now breached that contract, so the question becomes what your remedies are.
As an initial matter, the Uniform Commercial Code (some version of which has been adopted in every state except Louisiana) requires that contracts for the sale of goods in excess of a certain amount must be evidenced by a sufficient writing in order to be enforceable. The "certain amount" may vary between $500-5,000 depending on the specifics of your state's laws. We'll assume for the moment that this requirement is satisfied, but that may not be the case.
When a buyer breaches a contract for the sale of goods, the seller has two options: (1) sue for the difference between the contract price and the fair market value of the goods; or (2) sell the item to someone else and sue for the difference between the actual sale price and the contract price. In either case, the seller may also be entitled to certain costs associated with the transaction(s). Obviously, if you can sell the care to someone else for the same price by using the same free ad service, you have suffered no damages, in which case, you would be required to return the entire $400.
Be aware that your notion of teaching this person a lesson works both ways. You were just as "negligent" here (among other things by failing to reach a mutual agreement regarding the deposit and failing to document the transaction properly), so why shouldn't you be taught a lesson? In any event, that is a very juvenile mindset. Similarly, the suggestion of someone else that returning the money is "the right thing to do" ignores the possibility that you may have made a really good deal with this buyer that you might not be able to make with another buyer and, therefore, may actually be entitled to some real damages here.