I consider myself an experienced knitter and I have a terrible problem with this when knitting flat no matter what I do, so it is not because you are doing anything wrong! Have you tried pulling that stitch very tight?
One of the things that I think causes it is that when you get to the end of a row with only 1 or 2 stitches on the left needle, and the stitches on the left needle get stressed (by the knitting hanging down, or by pulling on the right needle), the stitches on the left needle getstressed and the slack gets pulled into them. See if avoiding this helps?
Also, knitting those loose stitches through the back loop (twisting them) will close them up a lot.