My understanding is that earlier Mel said they could only disconnect junction cars. When Layton arrives between the cars he looks at the wall and it says J something something, so he knows this is the right place. He gets ready to disconnect, then he notices the prisoners. He tries to save them but he knows he can't just go down one more car because it is not a junction.