BUG: Memory leak after failed RegisterFactory

If a RegisterFactory fails, the opened library was not closed. This
resulted in a memory leak.

This patch closes factories that fail to load.

Also, RegisterFactory now returns true if the factory loads and false
if it does not load.

Change-Id: If8cc37469b5d760d453b818d1c6a35058ab4d1ea
Merge topic 'ObjectFactoryMemoryLeak'

91d7549 BUG: Memory leak after failed RegisterFactory