By saying that the train will come in forty minutes, Hemingway is creatinig a certain amount of dramatic tension. The issue between the man and woman has to be resolved in forty minutes. He wants her to go to Madrid and get an abortion. She doesn't want to go through with it, and he knows it. She has consented, but he is not sure she won't change her mind. So he keeps tallking to her, tryig to persuade her that it is the right thing to do and that it is a very simple procedure and that it won't change their relationship. Meanwhile the train is approaching, as it is in the classic movie High Noon starring Gary Cooper. A so-called "ticking clock" is a common device in stories.
The fact that the train will stop for only two minutes shows that this is a small, insignificant station. This young couple may be the only passengers boarding here. I believe it is only a way of portraying the setting, although it also suggests the time pressure. They don't have to do anything during the forty minutes the train is approaching, but once it stops they will only have two minutes to decide to get aboard or stay where they are.