I don't have a Kvaser interface, but I suspect there is a race in your code between when stop_all_periodic_tasks is called and when you call shutdown. Skimming through the code for the Kvaser ...