To directly answer your question, the wall is only about 100 km from the airport. You do have time technically, and if you know someone locally you could give it a try. Or you could pay handsomely for a private taxi to take you there. Of course, that's just to see it. The touristy places where you can walk it, or take the gondola up to the top, will be closed and are further away. And there is the issue of traffic, which is hard to predict. You're outside the city already at airport, but you just never know with Beijing traffic. So the other recommendations make more sense.
Market is one option. I'd go straight to Tian An Men. Or if you're a bit more willing to walk around, I'd go to the rear of the Forbidden City. There's a nice park there, and you can climb the hill where you can see down into the Forbidden City and see the sunset. I don't recall how late that's open though. Regular parks and seeing the life of the older locals was always fascinating to me in Beijing; there are many around besides that tourist park behind Forbidden City, and they are open quite late. Houhai is great. Then I'd go for some good hot pot and/or duck. Shopping is plentiful if you want too, both legit and bargain.
Beijing taxis are not great at English still sometimes. Look for the Chinese names of the places you want to go, write them down in characters as best you can (or print them or email them to yourself so you can show phone, etc) to help. Watch out for touts (like black taxis). Take the train if you want, I prefer it because of traffic and it's easy to understand with English writing.