Add mutex release on error