"At-will employment" is a meme here. In reality, the company gives you a few months of pay and you sign a document saying you won't sue them for firing you during a layoff.
If you get fired for fraud or for being incompetent, for example, it's often different.