The motor man and conductor can look out the window to make sure nobody was leaving or entering the train. In some stations mirrors and cameras help out. The key thing though is that the doors are equipped with travel detection so that if they cannot close they will reopen.