Javascript: Issue with window.print

This works for me in current Safari and Chrome. The console log is executed after the print dialog is dismissed.

window.onafterprint = event => {
  console.log('after print');
};
window.print();