rewrite the function of close menu