State tax filing

Do you know if there is a form on the Maryland side that we can file if my work took out Maryland taxes even though I live in Virginia? Must I pay thousands Virginia says I owe, plus an underpayment penalty (because it looks like I became a self-employed person after I left my previous job in January where I had paid Virginia taxes)? And then also file a non-resident Maryland tax return to get a refund of all the state taxes I paid to Maryland? Is there any easier and cheaper way to go about this? If not, does it matter what order I do the state returns in TT? I already did the Virginia one but stopped in the middle once I realized why it said I owed so much.