I've been seeing a lot of modal windows lately, some which have the close button in the top right, some which have them on the top left. My guess is that this is because Windows has it in the top right and OS X has it in the top left. What are the best practices for the location of this button? Should it vary based on OS? Or should it consistently be in the top right/top left?
Sounds like you are talking about a web page? Trying to imagine another environment where such details are left to the designer/programmer.
I would tend to put it on the right. Granted, I mostly use MS Windows, but most cursors lean to the left, so it'd cover less content when hovering over the close button. Also, as most people are right-handed, the cursor is often slid to the right to remove it from view. If a popup were to appear, there would generally be less distance to cover to close it.
As always, I imagine it would depend on the exactly what effect you are trying to achieve and who your audience is.