You could make an array of tags that take closing tags, then run a function that attempts to find a closer for each tag in the text that's in the array. You'd need to allow for more than one instance of a particular opening tag, and it'd be difficult to get the closing tag in the right place, e.g. with nested tags.
BTW, the break tag (and all tags that don't take a separate closing tag) should be closed, too: "<br />".