fix: avoid segfault at exit when using custom memory functions
requested to merge flavorjones/libxml2:flavorjones-work-around-xmlcleanupparser-segfault into master
This extends the fix introduced by 956534e0 to Windows processes dynamically loading libxml2.
See #256 (closed) and https://github.com/sparklemotion/nokogiri/issues/2241 for background.
Closes #256 (closed).