Upvote:7
If you've got seven hours, I'd go for it. The city is indeed a bit of a hike away (~50 min), but since the connection is by subway, the trains are very frequent (every 5 min) and very reliable. To minimize hassle on return, make sure you have a boarding pass for your connecting flight before leaving the airport and time yourself to get back two hours before your flights, as immigration and security can be slow. This still leaves you with a good 2-3 hours of time to explore, and this site (no affiliation) has suggestions for various points of interest easily accessed from the airport, including travel times.
But if you've got only five hours, it's a bit more touch and go: it's technically possible, but you're unlikely to have more than an hour to actually see and do stuff, and staying at the airport would be the easy/safe option.