Back button issues

I have issues with back button when i use it on my mobile app.

document.addEventListener("backbutton", onBackKeyDown, false);

    function onBackKeyDown(e) {

        var leftp = app.panel.left && app.panel.left.opened;
            var rightp = app.panel.right && app.panel.right.opened;

            if ( leftp || rightp ) {

                app.panel.close();
                return false;

            }else if ($$('.modal-in').length > 0) {
              
                app.dialog.close();
                app.popup.close();
                app.sheet.close(".my-sheet-swipe-to-step");
                return false;

            } else if (app.views.main.router.url == '/') {

                    navigator.app.exitApp();

            } else {

                mainView.router.back();
            }


    };

the app goes back twice, and the tabs does not work when it goes back.

when i disable pushState:false it works fine but the back button does not work.

To understand better what i am saying, kindly download the app and install it.