To make forced input device release after log out actually work. Cherry-picked from upstream git head.