Exit modal onClick

Is there a way to exit modal operator after clicking the operator button again?
I initially thought about looking throught the list of handlers and remove the modal operator if it’s already on the list. But i looks like we don’t have access to it with the python api:

I solved it using global PropertyGroup. Don’t know if it’s a bit too hacky, still if anyone has another solution feel free to let me know :slight_smile: