avdevice/decklink: factorize cleanup function to common code