H1B extension before the expiration date and travel

I have to visit home country and my h1b expires in 15 September. Can I get extension sooner and then go outside country on 3rd September and return in October/november ? or should I stay in the country at the time of older visa expiration and transition to new visa ?

If I go now in a month or so then it’s unnecessary headache to deal with coming back and then filing extension. So I am thinking of getting all the stuff done here before going outside.

You can file your extension no earlier than within 180 days of the expiry of your current I-94.
While entering back you can show the new extended I-797 so that CBP can issue I-94 inline with the expiry of your extended H1B petition. Make sure you have a valid visa to enter back.