I realize now that I was naive, and many of you would probably say it was my own fault. I thought that if I did something that is not against the rules, things would be fine. Afterwards I found out though that entry into the US is completely the discretion of the border guards. Even if you are legally following the rules, they can deny you on a whim. In this case, I believe they thought I was taking advantage by just leaving the US for a few days and coming back. Which is a valid concern I guess, but if that's so, why wouldn't they put a time limit on how long you have to be away? I think part of my naivety comes from my trusting upbringing in a rural part of a small country.
Either way, it was not the best end to my 5 years in the US, and I doubt I'll be going back anytime soon. This experience just cemented once more that the US is not a country I wish to live in permanently, and have my kids grow up in.