Remove shared memory keys only if no segments are attached.