3D widget keeps mouse on screen

so, I’m using 3D widgets to make stuff look cool. I’m also using them as buttons to open doors(I might end up changing that, but we shall see). The big thing that I’m coming up with is that whenever I interact with a 3D widget, it keeps the mouse on screen even after i make it go away and I have to click back into the game afterwards in order to get back into the game. Does anyone out there know how to fix this? even if it is almost like a forced mouse input or simulating a click or something?