fixed bug on closing