Button is still "hovered" when unmaximize the window (Electron/CSS)

When I unmaximize my window of my app build using electron (if you don't know what it is, just think of chrome in its place) my mouse stays outside the window and the button still has a changed background color until my mouse re-enters the window. Basically until my mouse re-enters the window it thinks I'm still hovering on the button. How can I fixed this? I tried focusing the window when I clicked the button, but it didn't help with the problem. This isn't a major bug, but it annoys my ocd. I've noticed other electron apps like discord and slack have this too, so it might be unfixable.