You must even ignore cursing. Use a timer. Set the timer only when the child is quiet, i.e., not screaming, cursing, banging around, or using disrespectful language. After the time is over, open the door and permit the child to leave. There should be no further explanation, warning, or apology.
Some experts recommend a hug or affirmation of love.
Others say you should act as if nothing unusual has happened and don't hug or affirm love. I always hugged my children and told them I loved them. Regardless of hugs and love affirmations, always cheerfully welcome your grandchild back when the time-out is over. You may use the potential time-out for warning purposes. Be certain you only give one warning, though, and always follow through.