The last few weeks there have been many times when I released the 'W' key but kept on walking. The same thing happens with jumping, but it isn't as dangerous. I press ESC twice to stop.
It doesn't happen often, but it affects everything! It is so disheartening to be wearing your best diamond armor and carrying your best diamond tools or weapons and then walking into a pool of lava or off a cliff because walking didn't stop.
It sounds like the problem is with your keyboard. I'd suggest cleaning it. If that does not solve the problem then I think your keyboard has something underneath the keys causing it to stick or remain pressed. From there you can either get a new keyboard or attempt at removing specific keys and cleaning the backs of them. That one is risky depending on the keyboard.
I think I had that before, but not recently, maybe back in the days of 1.5. My keyboard was fine, it was a software glitch. The solution was to tap either A or D to stop walking - or hit the wall. If it's the same problem, it happened pretty rarely, only a few times.
I have "glitchy" chunks on the server I play on. Watch to see if the behavior is always in a certain area or happens all the time. If it happens all the time it's probably the keyboard. If it only happens in certain areas it could be something going on in those chunks. I got killed a couple times around lava in the same because of glitchy behavior. The program stores up a certain amount of walking and executes it all at once.
If you spilled soda or any sticky beverage on your keyboard the keys can glitch. I suggest cleaning your keyboard. If you can't clean it, try changing the controls with keys that work for walking until it will be fixed.