refactor(lock): Reworked CLI locking mechanism (refs #4504)

A lock is acquired by the CLI for data modification operations. If the
CLI cannot acquire the lock, then it exits immediatly (with exit code 1)
and does not waits for the lock to be released.