Fix crash when close