I've never done immigration in Chicago--couldn't deboarding, immigration, and the long walk to the Blue Line take at least one hour? Maybe more?
Then 40 minutes into town. Now you have a little over 4 hours before your next flight.
Walk to chosen restaurant--another 10 minutes or so. So let's say 2 hours from aircraft to restaurant.
If you take an hour to order and eat, it would be at least another hour getting back to the airport. Depending on the time of day (and your luck), you might have to wait a few minutes for the train.
So that should theoretically get you back to the airport about 2 hours before departure.
Anyhow, that's how I would estimate it as a regular visitor to Chicago. The natives might have a different perspective. But knowing how tired I am after a long transatlantic flight, I don't know if I would enjoy it much.