Fix a wrong handle closing.