From The Ethics, Part IV:
Human power is extremely limited, and is infinitely surpassed by the power of external causes; we have not, therefore, an absolute power to adapt things outside us to our use. Nevertheless, we shall bear calmly all that happens to us . . . so long as we are conscious that we have done our duty, and that the power which we possess is not sufficient to enable us to protect ourselves completely; remembering that we are a part of universal nature, and that we follow her order. If we have a clear and distinct understanding of this . . . the better part of ourselves will assuredly acquiesce in what befalls us . . . . For, in so far as we are intelligent beings, we can want nothing except what is necessary, nor be absolutely satisfied with anything except what is true.
And Part V:
The more this knowledge that things are necessary is applied to particular things . . . the greater is the power of the mind over the emotions . . . . For the pain arising from the loss of any good is mitigated as soon as the man who has lost it perceives that it could not by any means have been preserved.