I hope it's not too late to help here. This is something that often happens to me, and there are a few ways to fix it.
To understand why this happens, it's because Team Fortress 2 only loads ~2 GB of RAM when booted, meaning the game will automatically close if it's using anything more than ~2 GB of RAM.
So first, do you have any mods installed (.vpks in the custom folder)?
If so, they often create .cache files which can end up crashing the game. Try deleting the .cache files and see if there are any good results.
Additionally, the game can also crash due to a very large amount of in-game errors that eventually overflow the game's memory. Check console often to see if you have any errors while playing the game. If you do have errors, post them here.
Other than that, the fixes are very limited. Turning down graphical settings is definitely one of the fixes, but it's never the easiest one to do when you know that your PC can handle more than that.