Bite your tongue

Meaning: To stop yourself from saying something that may be rude, inappropriate or offensive.

Example: I wanted to argue with him, but I decided to bite my tongue.