fixed bug in train_losses based exit