Fix memory leak if using a old version of python-magic

This will fix a memory leak if a older version of python-magic is installed.  Closes the magic database the same way as in lib/cuckoo/common/objects.py.