properly lock/unlock resource.Release()

Signed-off-by: Nick Wade <nwade@pivotal.io>