diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx
index cff3db1f5d2163de5daf57f5f66bf45e17cbbccd..8a11fa83cf89b3d7ab431d091693a18994e2782c 100644
--- a/src/lib/project-saver-hoc.jsx
+++ b/src/lib/project-saver-hoc.jsx
@@ -45,9 +45,17 @@ const ProjectSaverHOC = function (WrappedComponent) {
         constructor (props) {
             super(props);
             bindAll(this, [
+                'leavePageConfirm',
                 'tryToAutoSave'
             ]);
         }
+        componentWillMount () {
+            if (typeof window === 'object') {
+                // Note: it might be better to use a listener instead of assigning onbeforeunload;
+                // but then it'd be hard to turn this listening off in our tests
+                window.onbeforeunload = (e) => this.leavePageConfirm(e);
+            }
+        }
         componentDidUpdate (prevProps) {
             if (this.props.projectChanged && !prevProps.projectChanged) {
                 this.scheduleAutoSave();
@@ -90,6 +98,15 @@ const ProjectSaverHOC = function (WrappedComponent) {
         }
         componentWillUnmount () {
             this.clearAutoSaveTimeout();
+            window.onbeforeunload = undefined; // eslint-disable-line no-undefined
+        }
+        leavePageConfirm (e) {
+            if (this.props.projectChanged) {
+                // both methods of returning a value may be necessary for browser compatibility
+                (e || window.event).returnValue = true;
+                return true;
+            }
+            return; // Returning undefined prevents the prompt from coming up
         }
         clearAutoSaveTimeout () {
             if (this.props.autoSaveTimeoutId !== null) {
diff --git a/test/integration/sounds.test.js b/test/integration/sounds.test.js
index ca1a3d275d8271e63af5068659429d4b4a4cee7e..3877ada3f8fa90acb8e866418fcc5ff1425b516d 100644
--- a/test/integration/sounds.test.js
+++ b/test/integration/sounds.test.js
@@ -32,6 +32,7 @@ describe('Working with sounds', () => {
 
         // Delete the sound
         await rightClickText('Meow', scope.soundsTab);
+        await driver.sleep(500); // Wait a moment for context menu; only needed for local testing
         await clickText('delete', scope.soundsTab);
 
         // Add it back