I‘ve changed my mind on this question over years. Because there isn't an absolute rule for all cases when we talk about whether to give up a thing or not.
I used to think we should always motivate ourselves in difficulties, because we need to catch the opportunity and at least we learn from the failures.
This is true, but may not adapt to everyone and every life stage.
Nowadays, I more and more agree with the thought that giving up or not giving up is just a choice under a specific situation. It's not and should not be a big deal in your long life. Don't put too much pressure on yourself, because life is about regrets and in most cases you actually have the second chance.
I prefer to have a peaceful and easy way to deal with my own life. So I think, we can just give up when we want to.