Assuming you're using window.showModalDialog to open the window (since window.open does not allow for return values), you'd just set the returnValue property of the modal and then set it to a variable in the opener.
Opener window:
var returnedValue = window.showModalDialog(url);
Modal window:
window.returnValue = 'foo';
window.close();
Thanks go to jbabey from SO for this.
If this helps please take time to accept the solution. And next time take time to search for the answer before asking. Thank you.