How long does a dose of meltonin stay in your system?
The half-life of melatonin is ~30 minutes to 2 hours. However, the amount of time it may take to clear from your system may be dependent on how long you've been using the medication. I recommend discussing with your physician if you're concerned about its effects. If you're taking it for sleep and it's making you too drowsy, you might take it earlier in the evening.
Here are some articles you might find useful:
Six Common Insomnia Myths
How to Reduce the Symptoms of Insomnia and Depression
Understanding Normal Sleep