I'll second the recommendation for staying in Madrid close to the Puerta del Sol. That way you can see some of the city, enjoy a good meal, and spend some time hanging around in a cafe and just soaking up the great night atmosphere. To get to T4 from Sol, it's about a half hour Cercanías ride (with a change at Chamartín train station, but it is a simple transfer). I personally wouldn't give that up to save a few minutes in the morning, unless I had to be at the airport at the crack of dawn. When I spend a night in Madrid before a flight home, I don't have to be at the airport any earlier than 9 am, and it's easy to get up at a reasonable hour, have my last café con leche, and get on a Cercanías to get me to the airport in plenty of time. I like the train over metro or bus, just because it is so much more regular and precise with its schedules. I know some people just like to be out near the airport for convenience, but with the excellent Madrid public transit system, it really isn't that much more convenient to stay out there.