First, check your setting for how long QBO will wait before it logs you off. You can find that under Company Settings - Advanced.
The next thing to note is that entering data does NOT constitute activity. Only Saving does.
So if you are working on a long transaction, make sure that you are saving the transaction every so often to ensure that QBO doesn't log you off automatically.