pgAdmin 4 v4 does not prompt to save on page refresh
Version pgAdmin 4 v4.2

There is a setting: File -> Preferences -> Browser -> Display -> Confirm on close or refresh

It worked fine.

I've created an issue here which is rejected: https://redmine.postgresql.org/issues/3993#change-15078

In pgAdmin 4 v4.1:
File --> Preferences --> Query Tool --> Options --> Prompt to save unsaved query changes?
Didn't work for me so I've updated to 4.2