First, you should unregister in reverse order you registered your operators, keymaps, etc.
Second, when registering keymaps you have to check keyconfigs are actually available (they are not in background mode).
- Blender/Python Addon Tutorial: a step by step guide on how to write an addon from scratch
- Blender/Python API Reference Usage: examples of how to use the API reference docs
Thanks to John Nyquist for editing these docs and giving feedback.