Hello, you should consult a psychiatrist to help you wean off this medication. It can be difficult, and depending upon the dose you are taking, even dangerous to attempt to detoxify yourself without medical supervision. You must be even more cautious if you are taking other substances along with modafinil like alcohol etc
Next Steps
Please consult a psychiatrist asap