Khazri scored the only goal for Tunisia when they beat defending champions France 1-0 win in the last group match which was still not enough to qualify to the next round.
The goal has seen Khazri join Saudi duo Salem Al-Dawsari and Sami Al-Jaber as the all-time leading Arab scorers at World Cups with three goals each.
"After the Tunisia match, and in a meeting that included all the players and the technical and administrative staff, I told everyone that this moment is appropriate, and I thanked everyone and wished them success," Khazri told Bein Sports French.
"I am proud of what I gave my country over the past years, and I believe that the future for this generation is bright."
"To beat France, to score and be decisive, that is more beautiful."
Tunisia began their World Cup campaign with a goalless draw against Denmark, then lost 1-0 to Australia in the second group game.
Khazri, who was born in France and played one game for the French national side in 2012, switched to play for Tunisia and won 74 international matches with them, scoring 25 goals along the way.