If you tell a girl that she needs to behave herself to get candy, you would say something like "Sally, behave yourself.". This is because the action is reflexive, and you would use self rather than selves because she is only one person.
The same thing goes for a person of unknown gender. If you are laying out the rules of a party, you would say that "Every party guest needs to behave themself or else they'll be kicked out." Again, the action is reflexive, and you would use self rather than selves because a party guest is only one person.
As the above commentator says, themselves is more commonly used in this situation than themself, mostly because the pronoun they has been considered a plural pronoun for so long. However, the pronoun you was in this situation before, so it has to be used as a guide in this context. If you use themself enough, you'll get used to it.