Bale, 32 -- who has featured in just seven Madrid games, starting four of them, in an injury-disrupted final season -- is out of contract this summer and departs having won five Champions Leagues and three LaLiga titles at the Bernabeu.
Sources close to Bale have told ESPN that no decisions will be taken on his future plans until after those games have been played.
"I write this message to say thank you to all my teammates, past and present, my managers, the backroom staff and to the fans that supported me," Bale wrote in a letter published on social media on Wednesday. "I arrived here nine years ago as a young man who wanted to realise my dream of playing for Real Madrid.
"To wear the pristine white kit, to wear the crest on my chest, to play at the Santiago Bernabeu, to win titles and to be part of what it's so famous for, to win the Champions League. I can now look back, reflect and say with honesty that this dream became a reality and much, much more.
"To be a part of this club's history and to achieve what we achieved while I was a Real Madrid player, has been an incredible experience and one I will never forget. I also want to thank president Florentino Perez, [managing director] Jose Angel Sanchez, and the board for giving me the opportunity to play for this club.
"Together we were able to create some moments that will live forever in the history of this club and football. It has been an honour. Thank you! HALA MADRID!"
A Real Madrid statement said: "Real Madrid would like to express its sincere gratitude and affection to Gareth Bale, a player who will forever be part of the club's legacy.
"He has experienced one of the most glorious eras in our history. Real Madrid is and always will be his home, and we would like to wish him and all his family the best of luck for the future."
Bale moved to the Spanish giants from Tottenham for a fee of around €100 million in 2013.
He was initially a key member of the team, scoring in their Champions League and Copa del Rey final wins in his first season and forming a formidable front three alongside Cristiano Ronaldo and Karim Benzema.
Bale scored twice in the 2018 Champions League final against Liverpool, including a spectacular overhead kick, but by that time his injury problems had become more frequent and his relationship with then-manager Zinedine Zidane had begun to suffer.
In 2019, Bale was on the verge of joining Chinese Super League side Jiangsu Suning, but the move broke down in the final stages after his agent Jonathan Barnett said Madrid changed their mind.
He was whistled by fans at the Bernabeu after he had been pictured with a banner that read: "Wales. Golf. Madrid. In that Order" while celebrating with international teammates in November 2019.
Bale spent the 2020-21 season back on loan at Spurs, scoring 11 goals in the Premier League, before returning to take a limited role back at Madrid under returning coach Carlo Ancelotti, who left him on the bench during last weekend's Champions League final in Paris.
Meanwhile, Madrid also confirmed Isco's exit after nine years at the club.
"Real Madrid would like to express its gratitude and affection to Isco, in which he has defended our badge and managed to become the legend of our club," the club said in a statement.