Hi,
It's a good practice to assign terminated users to a special user group (e.g. TERMINATED). If that was the case in your landscape you would not have any problem. You would just lock all users that belong to this special group. Other users would be unlocked.
You can have a look at change documents for lock.
Cheers