Fixed index OOB bug when stopping a service and unregistering handlers