Fixes #5923: System rule are modified when trying to delete a directive

Basically switch the deletion order so that if the directive can't be deleted, it is not removed from rules (because it's less a problem to have rules with unknown directives, we can still go delete them by hand)
what would happen if the directive has been removed, but cannot be removed from the rules for some reason ? does it fail nicely ?