Fix bug: keep track of removed executors properly

Our representation of the existing number of registered executors
was never updated when an executor is killed. Further, when an
executor is pending to be killed we never keep that into account
when requesting executors at the same time. This commit fixes
both of these cases.
Limit scope of synchronization

This commit decreases our reliance on `totalRegisteredExecutor`
to find the number of existing executors. It also minimizes the
scope of synchronization blocks to avoid potential deadlocks.