fix #777 Dispose of templates in the page engine.

Close #778