Fix a bug related on_close