Fix bug with cleanup running for locked tests

Code for lock aquiring modified.

- locks are aquired inside try statement,
 prevents from being interrupted outside of main flow
- prevent 500 error in case process was already stopped
- remove SIGUSR1 interrupt handler with SIG_DFL
 which simply returns 0

Change-Id: Icc31510db705b11c2b628604d0480d8da6aedeca
Closes-Bug: #1318631