Always exit via shutdown, so that things are cleaned-up properly.
Fix a couple of memory leaks in IOHIDCreateDeviceMatchingDictionary caused by not releasing keys.

Introduced an RAII-style Core Foundation wrapper class to simplify memory management.