Barriers close 5 minutes before departure, and the train is then shown as 'check out'.
Photos in this section are courtesy of Sunil Mehta.
Now the bad news: Foreigners cannot buy tickets at it's only in Chinese and only accepts Chinese bank cards (although if you happen to be an ex-pat with a Chinese bank card and a basic knowledge of Mandarin, you can follow these instructions for using 12306here).
So you should buy tickets through one of the following reliable recommended agencies, who charge a small fee. Or buy from a local train ticket agency for an RMB 5 fee.
However, a temporary shortening to 30 days in early 2017 seems to have become permanent.