one minor coding style fix.
refactor: abstracted the ngx.ctx releasing logic to eliminate code duplication.