You are right, the ending Hesse wrote was odd. I just thought it was a lapse into a diatribe.
You think he did it on purpose to make the point that the book shouldnt be taken too seriously?
“I am so wise; here let me unwisely show you the ways in which I am wise…”
Aka the book rejects dogma, so don’t make this book dogma it’s just a story, mate.