removing 'close' listener properly