Implemented proper thread and executor teardown.