So your hat kinda looks like this, with the tail coming out one end.
XX 0000000--------------- (tail)
what I do when finishing a hat is that I double over the tail yarn and pull it through the side where I put the XX's. I don't pull it out all the way though -- I use the doubled over end that I've pulled through and tie it in a knot to the end of the tail that's still poking out the side where the XX's are. --- does that make sense?
The main reason I like this method is that way there are two strands of yarn going through the live knit stitches -- that way on the odd chance that one strand breaks, you've got the other one.