How to expire session after 2 hours and also expire when browser closed?

It is the correct hook. I often also add a bit of javascript, to active the checkboxes inside the form.
In your case it would not be necessary to use the $accepted_args parameter – 3 – of the add_filter() hook, because you’re not using any parameters, and simply work with a return value as integer, in seconds.

if ( ! function_exists( 'keep_me_logged_in_for_1_year' ) ) {

    add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );
    function keep_me_logged_in_for_1_year() {

        return 31556926; // 1 year in seconds
    }

    add_filter( 'login_footer', 'set_default_true_on_checkbox' );
    function set_default_true_on_checkbox() {
        ?>
        <script type="text/javascript">
        document.getElementById( 'rememberme' ).checked = true;
        document.getElementById( 'wp-submit' ).focus();
        </script>
        <?php
    }

}

If you also want to check for a closed browser, then you need a check via javascript, that js should also be added via the hook login_footer. See this how to to learn more about the idea behind it.