Seconds matter in Japan's rail system [0]. Leaving early is (usually) a bigger problem than leaving late - but I doubt anyone was clamoring to get on the train in those last 20 seconds. But in the event a train runs late - get a 遅延証明書 from a station clerk.
[0] https://www.bbc.com/news/world-asia-42009839