Sometimes my window stays transparent

It seems like you accidentally triggered the AquaShake function, which makes a window transparent and "always on top" when you shake it. Shaking the window again should restore its normal state.

In the AquaShake tab of the configuration dialog, you can adjust the sensitivity of the function, or disable it totally if you want.

AquaShake settings