drupal_add_js() issues
drupal_goto() alters the header of the page, then calls exit(). So if it's placed before the drupal_add_js(), the function will never be called, and if it's placed after, the header says "Go some place else," and you will be redirected as soon as possible, not waiting for jQuery to execute.

Why do you need to close the shadowbox in the first place if you are going to redirect the user somewhere else? It sounds like there's a fundamental problem to what you want to do.