Fix NPE when closing MarcXMLWriter when Result constructor was used

Check that writer was set before attempting to use it in MarcXMLWriter::close.

Add a test case based on the sample code.