Optimal risk control and dividend policies under excess of loss