Restrict when to release locks going out of scope

Fixes #6

Forked processes must release their locks explicitly.
Merge pull request #7 from piojo/lock-fix

Restrict when to release locks going out of scope