Using a teleport command to get out of water while in the swimming animation causes it to be stuck. The player swims on land and is not able to toggle it off.
This also happens sometimes when you jump out of water.
- Setup a commandblock with the following command. Add repeaters to it so you have delay after activation
- Activate the contraption
- Get into a pool of water (at least two blocks deep) and press Shift to enter swimming mode
You are teleported while you're swimming, causing you to continue the swimming animation. Upon re-entering water the swimming animation gets deactivated.