KIJI-573. Added close/releaseIfNotNull to ResourceUtils.

@kryzthov.