Thanking the teacher
You won't be making a fool of yourself, we all appreciate a "thank you"...

You can choose to say in person, and your idea of "thank you for the learning experience" is good.

An email can also be fine, which you can send to arrive after the grades come out if that is a concern for you.

Do it, it will be fine. Or do both...

Edit, as Bob points out a handwritten note or card is also good.