The last train leaves at midnight and the next train doesn't start again until 6:00AM. You should be able to find a SIM card at midnight but I wouldn't count on it.
At that time traffic will be bearable so the trip should be quick - just have a price arranged before time with the driver before you get in and go.