Revert "Revert "fixed close""

This reverts commit 4057c69b57a310680c6a9e1827caabe1439bd6da.