bug fix on close operation