Shouldn't this be a fairly simple shellscript?
Just lsof for the device files in question and kill all processes of the logging out user that still have them open.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds