Since you currently reside in Maryland, you can file for divorce in Maryland, regardless of where you were married. If your husband is in another state, often it can lengthen the amount of time it takes to actually get divorced. A competent family law attorney can help guide you through this process.
You are correct that your H4 visa depends on the validity of your marriage. You will lose your H4 status upon the final divorce decree, regardless of the date stamped on your I-94 card. So, you definitely want to plan ahead and most likely make your change of nonimmigrant status before finalizing the divorce. Your educational level and your objectives will help us narrow the options.
Here are just some possible visa options during/after divorce:
1. B-2 Visitor, just to wrap your affairs and leave.
2. F-1 Student, to study full time
3. H1B Worker, if you have a job offer in a profession i.e. education, engineering, computer science etc. and you have at least a Bachelor's degree in the matching specialty.
Please feel free to schedule your Free 30 Minute Initial Consultation with me to get a more reliable picture of your visa options and the best timing filing.