Normally, when you get your passport and visa back from the consulate, is around 2:30 pm. This is a little late to try and get through Pedang Baser on the train. Also, bear in mind that the buses from PB to Hat Yai stop at 7 pm and there are only dreadful short-time hotels. Not a place to stay as a tourist. Best to stay one more night in Penang and set off after breakfast.
I've found coming back via the train is one of the easiest border crossings ive done entering thailand.
This is an excellent page for good advice. If you want gossip and anecdotal advice that can't be relied on perhaps you should post on this other unmoderated page.
You might not realise/believe that if you get stopped by the police as an overstayer, prior to getting to immigration, you'll be off to the IDC then eventually deported at great expense and banned.