Some locks were not being properly cleaned up during close down. Reviewed-by: Richard Levitte <levitte@openssl.org>