The length of track over which a train is allowed must be reserved in advance of its movement on that section. So the sequence of events may go something like:
Level crossing gate is closed,
This information is relayed to the master of station in the rear,
Signal is lowered for a train waiting at (or approaching) the station,
The train begins to roll out from the station (or can move through it).
All of this might take a few minutes if the level crossing gate is a little distance away from the station.