Closeable api 1.6.x

cherry-pick of issue #1503