implements the thread shared memory free callback