This expression is used when one thinks that something will never happen. For instance, when people say, “I’ll apologize when hell freezes over,” it means they don’t intend to apologize ever.