How to run a stage on if previous state fails

I have a pipeline where at the end of stages, I kept one stage to do a cleanup. But I need this stage to run only if the previous stage of it fails.

In the previous stage, I set allow_failute true to continue next commands in stage. I don’t know because of this or not, stage is skipping. Can you please guide