Fixed a potential double free when close() is called upon FIN event