Just like training your dog, it takes patience. Redirect them and let them know you're displeased with them.

Unfortunately, it's a bit harder with older chickens to teach them who's boss. You don't have to be mean, just firm. Keep in mind that it will almost definitely take more patience than training a dog, though.