diff --git a/web/pgadmin/browser/register_browser_preferences.py b/web/pgadmin/browser/register_browser_preferences.py
index 5bee817e..c7ea8126 100644
--- a/web/pgadmin/browser/register_browser_preferences.py
+++ b/web/pgadmin/browser/register_browser_preferences.py
@@ -38,6 +38,16 @@ def register_browser_preferences(self):
         )
     )
 
+    self.preference.register(
+        'display', 'confirm_on_refresh_close',
+        gettext("Confirm on close or refresh ?"), 'boolean',
+        True, category_label=gettext('Display'),
+        help_str=gettext(
+            'Confirm closure or refresh of the browser or browser tab is '
+            'intended before proceeding.'
+        )
+    )
+
     self.table_row_count_threshold = self.preference.register(
         'properties', 'table_row_count_threshold',
         gettext("Count rows if estimated less than"), 'integer', 2000,
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index cc2ea056..2accd182 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -1991,10 +1991,18 @@ define('pgadmin.browser', [
     pgAdmin.Browser.editor_shortcut_keys.Tab = 'insertSoftTab';
   }
 
-  $(window).on('beforeunload', function() {
-    let pref = pgBrowser.get_preference('browser', 'browser_tree_state_save_interval');
-    if (!_.isUndefined(pref) && pref.value !== -1)
+  $(window).on('beforeunload', function(e) {
+    let tree_save_interval = pgBrowser.get_preference('browser', 'browser_tree_state_save_interval'),
+      confirm_on_refresh_close = pgBrowser.get_preference('browser', 'confirm_on_refresh_close');
+    if (!_.isUndefined(tree_save_interval) && tree_save_interval.value !== -1)
       pgAdmin.Browser.browserTreeState.save_state();
+
+    if(confirm_on_refresh_close.value) {
+      /* This message will not be displayed in Chrome, Firefox, Safari as they have disabled it*/
+      let msg = S(gettext('Are you sure you want to close the %s browser?')).sprintf(pgBrowser.utils.app_name).value();
+      e.originalEvent.returnValue = msg;
+      return msg;
+    }
   });
 
   return pgAdmin.Browser;
diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py
index b75e18a0..deee7a4f 100644
--- a/web/regression/python_test_utils/test_utils.py
+++ b/web/regression/python_test_utils/test_utils.py
@@ -649,55 +649,73 @@ def get_db_server(sid):
 def set_preference(default_binary_path):
     conn = sqlite3.connect(config.TEST_SQLITE_PATH)
     cur = conn.cursor()
-    perf = Preferences.module('paths')
-    server_types = default_binary_path.keys()
 
+    paths_pref = Preferences.module('paths')
+    server_types = default_binary_path.keys()
     for server in server_types:
-        path_pref = perf.preference('{0}_bin_dir'.format(server))
+        pref_bin_path = paths_pref.preference('{0}_bin_dir'.format(server))
         user_pref = cur.execute(
             'SELECT pid, uid FROM user_preferences '
-            'where pid=%s' % path_pref.pid
+            'where pid=%s' % pref_bin_path.pid
         )
 
         user_pref_data = user_pref.fetchone()
         if user_pref_data:
             cur.execute(
                 'UPDATE user_preferences SET value = ? WHERE pid = ?',
-                (default_binary_path[server], path_pref.pid)
+                (default_binary_path[server], pref_bin_path.pid)
             )
         else:
-            params = (path_pref.pid, 1, default_binary_path[server])
+            params = (pref_bin_path.pid, 1, default_binary_path[server])
             cur.execute(
                 'INSERT INTO user_preferences(pid, uid, value)'
                 ' VALUES (?,?,?)', params
             )
 
-    conn.commit()
-    conn.close()
+    browser_pref = Preferences.module('browser')
 
+    # Disable tree state save for tests
+    pref_tree_state_save_interval = \
+        browser_pref.preference('browser_tree_state_save_interval')
 
-def disable_tree_state_save():
-    conn = sqlite3.connect(config.TEST_SQLITE_PATH)
-    cur = conn.cursor()
-    pref = Preferences.module('browser')\
-        .preference('browser_tree_state_save_interval')
+    user_pref = cur.execute(
+        'SELECT pid, uid FROM user_preferences '
+        'where pid=?', (pref_tree_state_save_interval.pid,)
+    )
+
+    if len(user_pref.fetchall()) == 0:
+        cur.execute(
+            'INSERT INTO user_preferences(pid, uid, value)'
+            ' VALUES (?,?,?)', (pref_tree_state_save_interval.pid, 1, -1)
+        )
+    else:
+        cur.execute(
+            'UPDATE user_preferences'
+            ' SET VALUE = ?'
+            ' WHERE PID = ?', (-1, pref_tree_state_save_interval.pid)
+        )
+
+    # Disable reload warning on browser
+    pref_confirm_on_refresh_close = \
+        browser_pref.preference('confirm_on_refresh_close')
 
     user_pref = cur.execute(
         'SELECT pid, uid FROM user_preferences '
-        'where pid=?', (pref.pid,)
+        'where pid=?', (pref_confirm_on_refresh_close.pid,)
     )
 
     if len(user_pref.fetchall()) == 0:
         cur.execute(
             'INSERT INTO user_preferences(pid, uid, value)'
-            ' VALUES (?,?,?)', (pref.pid, 1, -1)
+            ' VALUES (?,?,?)', (pref_confirm_on_refresh_close.pid, 1, 'False')
         )
     else:
         cur.execute(
             'UPDATE user_preferences'
             ' SET VALUE = ?'
-            ' WHERE PID = ?', (-1, pref.pid)
+            ' WHERE PID = ?', ('False', pref_confirm_on_refresh_close.pid)
         )
+
     conn.commit()
     conn.close()
 
diff --git a/web/regression/runtests.py b/web/regression/runtests.py
index 0284753c..4faf70c6 100644
--- a/web/regression/runtests.py
+++ b/web/regression/runtests.py
@@ -419,9 +419,6 @@ if __name__ == '__main__':
             if server['default_binary_paths'] is not None:
                 test_utils.set_preference(server['default_binary_paths'])
 
-            # Disable tree state saving
-            test_utils.disable_tree_state_save()
-
             suite = get_suite(test_module_list,
                               server,
                               test_client,
