Depends on how well you want to do? Do you want to match in a competive internship?Do you want to just pass? Do you need to take it to graduate? I think these questions are more important in when to take it, then whether to take it before or after shelf? Is there a reason you want to take it within a week of your shelf? Do you think you would be ready by then?
Just based on your question, I would take it after your shelf, because, you are probably going to focus on IM for your shelf and not be able to review other stuff i.e peds, surgery... So, if you take it after, you have the IM stuff down, and then you just need to augment it with the other stuff...And, you wont detract from studying IM with the other stuff.