Check if name_space handler exists

I made a reusable overlay handler that just prints some text and then gets removed after n seconds, I need to remove the handler if it exists, I am currently doing this (which is horrible code I know):

name_space = bpy.app.driver_namespace
if name_space.get("overlay") is not None:
if str(name_space["overlay"].handler).startswith('<capsule object "RNA_HANDLE"'):
name_space["overlay"].remove_handler()


How do I sensibly find out if the value is "RNA_HANDLE" or "RNA_HANDLE_REMOVED"?