When you enable the Receive Direct Messages from anyone setting, anyone can message you, even if you do not follow them.
If you previously had a conversation with a person through Direct Message, that person is able to message you regardless of if you follow them or not.
Disabling the Receive Direct Messages from anyone setting does not stop accounts from messaging you whom you have previously had conversations with and do not follow.
To stop receiving Direct Messages from someone:
Locate the conversation from the account, and click or tap to open it.
Click or tap the information icon {{ twtr-rte-icon:information_circle }}
Select Report.
Confirm your choice. The account will not be able to send you a message until you send them a message first.
Alternatively, to stop receiving messages, you can block the account. Blocked accounts cannot send you messages, unless you unblock them.