Fix lock destruction/unlock inversion

When using scoped locks, the unref of an AO2 object should happen after
the unlock occurs which requires usage of scoped refs.


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@383377 f38db490-d61c-443f-a65b-d21fe96a405b