call devices closing function on module close