Ondownload | filename | true works for me. The TRUE is important, it makes the macro wait for the download to complete.
Also, ONDOWNLOAD must be in the macro before the click command that triggers the download.
See this GIF, the line with the CLICK command waits until the download is complete. During this time you see the download count down in the top status bar:
