Ensure closing tags are appended when using custom word boundaries

This looks like it was a goof on my part when adding the custom word boundaries feature in the first place :). Added a failing test case and some code to ensure that closing tags are handled correctly.