Fix MiscUtils: closeSilently should check for nullity, close #662