You may encounter many defeats, but you must not be defeated. In fact, it may be necessary to encounter the defeats, so you can know who you are, what you can rise from, how you can still come out of it.
If you have done the best you can do and if you have gotten all you could extract from something, you have given all you had to give, then the time has come when you can do no more than say thank you and move on.