some code before go to sleep