Add shutdown method to dispatcher so that it waits for running threads to complete.