Both are fine.
We can use the verb "shake" informally to mean get rid of, or put an end to, something.
We can also use the phrasal verb "shake off" to successfully deal with, or recover from, something.
If I had to choose, I would use "shake" for both your examples.