Don't add a move to the history until promotion has taken place, otherwise the history contains a pawn on the final rank.