There are a couple of common culprits behind getting kicked offline mid-game.
First, some browser games treat certain keys, like the backspace key, as navigation commands. Pressing them can bump you straight out of the game, so it's worth learning which keys to avoid.
Second, heavy traffic on a server can cause congestion. When too many people are online at once, connections can time out and drop you. If that's the issue, trying again during off-peak hours or on a less crowded server often helps.
A stable internet connection and an up-to-date browser also go a long way toward keeping you in the game.