Changes to shutdown sequence and the command handler

- Made some changes to PyMata shutdown, arduino is reset to restore all pins etc to default state, and the slave threads are explicitly shut down
- Made some changes to try improve the robustenss of the command handler.
    * All uses of data_lock are now done using a 'with' block so that the lock is released if an exception is thrown
    * The command handler loop has now been wrapped in an exception handler to cope with invalid data coming from firmata
    * Timeouts have been added to all potentially blocking loops