Try exploring the local area around you
Most people in Tokyo either intend on staying out all night, until the trains begin in the morning, or make it a point to get to the station early, even before the very last train to their respective destination. However, if you're one of the many who with every intention of returning home for the night find yourself stranded, you need to think of a solution. If you have energy, in my opinion this is a great opportunity to try some back street walking. Downtown Tokyo has two very different faces, and seeing the night version can yield both interesting encounters, and a chance to do people watching of a different breed. Downtown places like Kabukicho is entirely nocturnal after all. I wouldn't worry too much about safety, as the stories of Yakuza encounters in back alleys was ultimately a very rare thing in the distant past.