One example where you may receive cash back is if you took out a VA loan which requires no down payment. Suppose you gave $1200 earnest money deposit, received a $2000 seller credit for closing costs, and your actual closing costs were $2500. Your costs were 2500, minus your 2000 credit, equals 500 you owe. You already gave a 1200 deposit, so you would receive $700 back at closing.
That is a very basic example. The actual closing numbers will be much more complex. Hope I didn't confuse you. :-)
Generally a lender will not permit cash to the borrower at closing. Your loan officer and agent should discuss what the closing costs will likely be and your offer should be a specific number, $X,000 toward buyers allowable closing costs and prepaids. If the actual closing costs exceed the amount, you'll need to come up with some cash. If there is extra your lender can possibly use the excess to buy down your rate or it would typically be returned to the seller.