Arranged doClose() to check null strictly.