President Obama is feeling good about his chances at re-election -- if he could run again. 

The president went off-script Tuesday during his address before the African Union, as he talked about the importance of term limits. 

After citing the example of the U.S. presidency, he quipped: "I actually think I'm a pretty good president. I believe if I ran again, I could win." 

"But I can't," he added. 

Obama later said, "I don't understand why people want to stay so long, especially when they've got a lot of money." 

More On This...

The speech in Ethiopia marked the end of Obama's five-day visit to Africa that included an earlier stop in Kenya, homeland of his late father. 

While touting Africa's potential, he used much of the speech to press for reforms throughout the continent. Obama called on Africa's leaders to make their countries more attractive to foreign investment by cleaning up corruption, upholding democratic freedoms, supporting human rights, and willingly and peacefully leaving office when their terms expire. 

His remarks on term limits referred to Burundi's leader, who was just elected to a controversial third term although he is constitutionally limited to two. The announcement that President Pierre Nkurunziza was seeking a third term sparked days of unrest across the country. 

"There's still so much I want to get done to keep America moving forward. But the law is the law and no one is above it, not even presidents," Obama said. "And, frankly, I'm looking forward to life after being president. It will mean more time with my family, new ways to serve, and more visits to Africa." 

He called on the AU to use its authority to help make sure African leaders stick to their term limits and follow their constitutions. "No one should be president for life," said Obama, who leaves office in January 2017. 

The Associated Press contributed to this report.