There is a bug in Anomaly Detection. Let's say I haven't set it up yet. When I open Anomaly Detection, it prompts me to add metrics. If I choose "Cancel", the metrics selector goes away momentarily, but then it returns again. Pressing "Cancel" repeats the loop.
So upon pressing "Cancel", instead of sending me through an infinite loop, perhaps I could be shown a message that talks about the benefits of Anomaly Detection and the steps for setting it up.
Anomaly detection can't run without metrics which is why it forces the user back into the metric selector to choose at least one metric. If you do have at least one active metric selected and then go back to the metric selector it does close out properly if you click cancel in my experience.
I recommend posting your feedback on the user experience enhancements to the Idea Exchange to bring to the attention of Product Management.