Module blocks invalidate markup

The closing tags </ktml:modules> are not being removed from the rendered content. This is causing layouts to break and markup validation will fail as well.
This patch solves it by catching the closing tag and removing it.