Looks like getTopmostWindow() may have changed a bit.
In v3 it returned the window object, in v4 it returns the id.
In v4, to duplicate the v3 functionality this is needed:
var topId = windows.getTopmostWindow(false);
var top = windows.window(topId)