Fix fatal error when removing hooks

Signed-off-by: margarett <bruno.m.alves@gmail.com>