IRS Publication 521 covers Moving Expenses.
According to Pub 521, in order to deduct moving expenses, there are three requirements that you must meet, one of which is called the time test:
Time Test for Employees
If you are an employee, you must work full time for at least 39 weeks during the first 12 months after you arrive in the general area of your new job location (39-week test). Full-time employment depends on what is usual for your type of work in your area.
For purposes of this test, the following four rules apply.
You count only your full-time work as an employee, not any work you do as a self-employed person.
You do not have to work for the same employer for all 39 weeks.
You do not have to work 39 weeks in a row.
You must work full time within the same general commuting area for all 39 weeks.
Yes, the 39-week employment period is a requirement. However, the 39 weeks do not have to be consecutive nor with the same employer. Also, the 39 weeks do not have to be complete before taking the deduction. Pub 521 goes on further to explain this in the section Time Test Not Yet Met. Essentially, you can deduct your moving expenses if you think that you will meet this 39-week requirement over the 12 months following your move. If you decide to take the deduction and then it turns out that you did not meet the 39-week test, you must fix it by either amending your tax return or adding the deduction back in as "extra income" on the next year's return. Pub 521 also lists exceptions to the 39-week rule which will get you out of the time test, (including getting laid off), but quitting is not one of them.
Since you have already left the area, you will not meet this 39-week test and should not deduct the expenses for that move. However, in moving back to your home state, you have made a new move that might be eligible for deduction, depending on your job situation.