main/formats: Fix crash in ast_format_cmp during non-clean shutdown.

* Backport ast_register_cleanup from Asterisk 12.
* Use ast_register_cleanup for format_attr_shutdown.

ast_register_cleanup was originally commited in r390122 by dlee.

(closes issue ASTERISK-23103)
Reported by: JoshE


git-svn-id: http://svn.asterisk.org/svn/asterisk/branches/11@411310 f38db490-d61c-443f-a65b-d21fe96a405b