President Obama on Sunday said it has been "the privilege of my life" to serve as the head of the U.S. military.

Obama and first lady Michelle Obama visited U.S. troops at Marine Corps Base Hawaii in Oahu's Kaneohe Bay.

It was the last time Obama will take part in his annual Christmas tradition as president.

President Barack Obama and first lady Michelle Obama at Marine Corps Base Hawaii, in Kaneohe Bay, Hawaii, Sunday, Dec. 25, 2016. Carolyn Kaster / AP

But Obama said his gratitude to the military won't stop once his term ends. He said his commitment to standing by the military "every step of the way" continues.

The president noted that U.S. troops are serving on Christmas in dangerous places like Iraq and Afghanistan, with some engaged in missions against the ISIS.

He said they should know that Americans understand that they serve every day to protect U.S. freedoms.

"It's important to hear from us that what you do matters, and that we know about it, and that we're grateful, and that we'll stay grateful even when many of you end up being out of uniform and are veterans, and that we make sure that we're serving you as well you served us," Obama said.

"So I just want all of you to know that it has been the privilege of my life to serve as your commander in chief," he added. "I know Michelle feels the same way when it comes to being able to stand alongside our military families and our veterans. And although this will be my last time addressing you as President, I want you to know that, as a citizen, my gratitude will remain and our commitment to standing by you every step of the way — that won't stop."

The White House said Obama and his wife and daughters spent Sunday morning at their vacation rental playing games and opening Christmas gifts.