Add missing mutex unlock if an error is hit.

Spotted by dhill.