Fix bug close event

Fix bug close event and remove some useless functions.