Close menu on machine back button

I have 4 pages login, home, home2 and contact us. My menu is being used on home2 and contact us page only.When I navigate from home -> contact us page and open menu, then i press mobile back button or browser back button it moves back to home page with that menu open.
Can anyone help me out with this.
TIA :slight_smile: