That stuck situation is usually related to an infinite loop, that results from a bug in the code. What you suggest may be implemented, but the method used to accomplish that will eventually lead to resources not being freed, locked files remaining locked, etc. Not the ideal solution.
I prefer to have users complaining about the problem and, with their help, fix the bug.