I tend not to give gifts that will require handwashing ... in my world, "hand wash only" translates to "I will never, ever wear this". Personally, I don't buy items that require handwashing because I know I will not handwash it, so I don't expect anyone I give a knitted gift to handwash either.
If the yarn you've used is machine washable (check out the label before buying) then it shouldn't be a problem. Be sure that you have woven in all loose ends to ensure that nothing unravels. Personally, I do the following to try to protect my knitted projects as much as possible during washing:
1) I wash the item alone or with a few other small items that are similar (this means don't put it in with heavy/rough items, such as jeans, etc.);
2) I only use the "delicate" cycle on my machine;
3) I usually place the item in one of those laundry bags that you can get for delicate items (a zippered pillowcase will do the same thing) to further protect it.
Hopefully you'll find some of that helpful, as I'm not sure exactly what happened during your last washing experience! If you didn't do one of these things and think it might have helped, then I would give it another go and see if you get a better result next time!