Close returns a Future and it is possible to wait for all tasks to complete before closing