Herding interactions as an opportunity to prevent extreme events in financial markets