The last train from Osaka to Kyoto departs at 10:30 pm. If you miss it, the next one is scheduled for 6:00 am in the morning.