I must be cruel to be kind and stop your bad habit.
be cruel to be kind
idiomTo act cruelly in order to achieve a positive outcome in the future.
Origin
disputed originFrom William Shakespeare's Hamlet, Act 3, Scene 4: "I must be cruel, only to be kind: / Thus bad begins and worse remains behind."
The doctor had to be cruel to be kind by forcing the patient to walk immediately after the surgery.
By refusing to provide the funding that had enabled his son's recklessness, the father was being cruel to be kind, hoping to finally teach him the value of responsibility.