If a train cannot leave the current station because all other stations are fulfilled, it becomes stuck until it is manually restarted. I would suggest flagging trains where this condition exists, and then periodically iterate through the list of flagged trains to see if they have a valid station, and if so, get them rolling again.