Prilosec is not terribly expensive (or cheap for that matter) and probably is worth a try. Walmart usually has the cheapest price, and its on sale there now. It takes up to four days to be effective.
Technically the word for no being able to stop thinking about an ex is obsessive thinking. And while the label in somewhat unpleasant it is no where near as unpleasant as doing it. Do you have access to a counselor?
The following link may have useful info -
Cognitive behavioral therapy - Wikipedia, the free encyclopedia
In any event most of us guys have been through this, as bad as it seems we usually recover - and in retrospect are glad about the breakup.