Fixes xml strings that aren't closed

The parser never returns if given strings like "<test><foo>" when calling parseString() because the sax close() method was never called.

This fixes that by calling close on the sax write stream.

Note that the unit test that covers throwing an error synchronously was in my opinion actually wrong, since an error generated synchronously does and should bubble up immediately - so I flipped the logic of the unit test and added an appropriate comment.