Safe entity removal with locking