Toggle full-screen-api.exit-on-deactivate in about:config (type it in the address bar).
full-screen-api.exit-on-deactivate
about:config
Tags: browser