Make the hooking and unhooking of the interrupt interrupt safe.