You know I'm a sucker for ramen... and Ichiran has a chain a short 45 minutes for Osaka Airport. Throw in a shorter immigration line than Narita and you're there and back in under 3 hours.
They don't have to be. Check your heavy luggage and pack some extra clothes in your carry on. Then leave the airport. Go eat something you've always wanted to try. Or maybe, you've already been there. Go eat something you loved the last time you were there. For me and Japan, it's always ramen.
If it's the first time in that city, walk around and explore it. Get a little lost. Keep an eye on time and if you're ever too lost, you're always a taxi away from a train station or the airport. Get a feel for that city so you know what to do the next time.
Shanghai on a layover. You can leave the airport on a transit visa for free as an American for 72 hours. Not bad, considering a Chinese visa is normally a couple hundred.
If you're uncomfortable, research Trip Advisor or other forums beforehand for similar situations. You're not the first person to take that flight. Someone else has had the idea to leave the airport. See where they went. I found a random mall in Bangkok for a quick bite and cheap shopping on a long layover. In the end, it was cheaper to take a cab and eat there than it would have been to eat airport food.
I recently had a crazy long 16 hour layover in Guam. It was so long, I couldn't check my bag all the way through. I was frustrated because I had to carry my checked bag around as I explored. I took a cab to the closest hotel where there happened to be a public beach next door. I walked over to quickly explore. There, I saw a random guy swimming in the water... with a snorkel on. So I figured since I had my snorkel and swim suit in my bag, why not check it out myself.
It was incredible. It was easily some of the best snorkeling of my life. So many fish, so clear, so close up, and so... random.
Ypao Beach Park, Tumon Bay. Amazing (and free!) snorkeling