Social authentication in pop-up window - but how do I close it?

Social authentication in pop-up window - but how do I close it?

I'm planning to have the following functionality -

1. User clicks on social login button.
2. A pop-up window opens, which shows social authentication screen (viz. FB, Google, LinkedIn)
3. User logs in and allows the app to access data.
4. Gets redirected to the main app - at which point, the main browser window refreshes and the pop-up closes automatically.

I've been able to get the functionality working till point 4 but only till redirect. I've no clue how to close the pop-up window after it's redirected the user. Here's my code

  1. $(document).on('click', '.socialLoginButton', function(e) {
  2.         e.preventDefault();
  3.         let provider = $(this).attr('data-content');
  4.         let left  = ($(window).width() / 2) - (900 / 2),
  5.             top   = ($(window).height() / 2) - (600 / 2);
  6.         let popup = window.open("/login/"+provider, "popup", "width=900, height=600, top=" + top + ", left=" + left);
  7.         popup.redirectEnd.close(); // <--- This won't work. 
  8.     });
Would really appreciate if someone could show me a way to achieve this. 

PS: Also wish to know if pop-up, in general is a good approach. I'm not sure how does browser decide when to block pop-ups and when to allow them. 

I thank this wonderful community and look forward to receiving some help.