Properly kill processes holding CFEngine locks (Redmine #2330)

Backport Mikhail's abf7f75e from master.