protected function handleShutdowns() {
        declare(ticks = 1);

        $self = $this;

        $cleanup = function($signal = null) use ($self) {
            if ($signal === SIGTERM) {
                fprintf(STDERR, 'Received SIGTERM...');
            } else if ($signal === SIGINT) {
                fprintf(STDERR, 'Received SIGINT...');
            } else if ($signal === SIGTSTP) {
                fprintf(STDERR, 'Received SIGTSTP...');
            }

            $self->deleteAllLocks();
            exit;
        };

        if (extension_loaded('pcntl')) {
            pcntl_signal(SIGTERM, $cleanup, false);
            pcntl_signal(SIGINT, $cleanup, false);
            pcntl_signal(SIGTSTP, $cleanup, false);
        }

        register_shutdown_function($cleanup);
    }