ndb_thread: port to use std::thread + cleanup