Warn user onbeforepageunload when db queries haven't finished. Fixes #277