Fix MiscUtils: closeSilently should check for nullity

Speaks for itself: not checking for nullity made some tests fail and it's quite possible this could cause NPE outside tests too.