I've had the last train out of central London for the night cancelled at about 1am and you can just message the train company on social media and they'll pay £100+ to get you a taxi all the way to somewhere like Cambridge.
Also, not sure how it is in other countries, but in the UK, everything is entirely open data. You can go to a site like https://map.signalbox.io/ to see a live map of every train in the UK, and sites like Realtime Trains let you get all the details about every train (eg. https://www.realtimetrains.co.uk/search/simple/gb-nr:KGX)