function _closeWindow(window, flow, asModal, view) {
    var index = OS_ANDROID && flow.children.indexOf(window) || 0;

    if (asModal) { return window.close(); }
    if (index === -1) { throw("Window already closed"); }

    OS_ANDROID && flow.withDrawer && (function removeFromStack(view, flow) {
        var index = flow.viewStack.indexOf(view);

        if (index === -1) { throw("View already closed"); } // Really weird if happens.

        window.remove(_drawer);
        if (index === flow.viewStack.length - 1) {
            /* Closing the last window, the one displayed in the drawer */
            _drawer.setCenterView(flow.viewStack[index - 1]); // There is at least 2 views
            if (flow.children.length > 1) { // There are previous windows
                flow.children[index - 2].add(_drawer);
            } else { //Otherwise, back to the root
                flow.root.add(_drawer);
            }
        }
        flow.viewStack.splice(index, 1);
    }(view, flow));

    OS_ANDROID && flow.children.splice(index, 1);
    window.close();
}
/**
 * @method _closeWindow
 * @private
 *
 * Close the given window of the given flow
 *
 * @param {titanium: UI.window} window The window to be closed
 * @param {Object} flow A representation of a flow
 * @param {Boolean} asModal Close the modal window without impacting the flow
 */
@method _closeWindow
@private

Close the given window of the given flow

@param {titanium: UI.window} window The window to be closed
@param {Object} flow A representation of a flow
@param {Boolean} asModal Close the modal window without impacting the flow
@method _closeWindow @private Close the given window of the given flow @param { titanium : UI . window } window The window to be closed @param { Object } flow A representation of a flow @param { Boolean } asModal Close the modal window without impacting the flow
function _closeWindow(window, flow, asModal, view) {
    var index = OS_ANDROID && flow.children.indexOf(window) || 0;
    if (asModal) { return window.close(); }
    if (index === -1) { throw("Window already closed"); }
    OS_ANDROID && flow.withDrawer && (function removeFromStack(view, flow) {
        var index = flow.viewStack.indexOf(view);
        if (index === -1) { throw("View already closed"); } 
        window.remove(_drawer);
        if (index === flow.viewStack.length - 1) {
            _drawer.setCenterView(flow.viewStack[index - 1]); 
            if (flow.children.length > 1) { 
                flow.children[index - 2].add(_drawer);
            } else { 
                flow.root.add(_drawer);
            }
        }
        flow.viewStack.splice(index, 1);
    }(view, flow));
    OS_ANDROID && flow.children.splice(index, 1);
    window.close();
}
function _closeWindow ( window , flow , asModal , view ) { var index = OS_ANDROID && flow . children . indexOf ( window ) || 0 ; if ( asModal ) { return window . close ( ) ; } if ( index === - 1 ) { throw ( "Window already closed" ) ; } OS_ANDROID && flow . withDrawer && ( function removeFromStack ( view , flow ) { var index = flow . viewStack . indexOf ( view ) ; if ( index === - 1 ) { throw ( "View already closed" ) ; } window . remove ( _drawer ) ; if ( index === flow . viewStack . length - 1 ) { _drawer . setCenterView ( flow . viewStack [ index - 1 ] ) ; if ( flow . children . length > 1 ) { flow . children [ index - 2 ] . add ( _drawer ) ; } else { flow . root . add ( _drawer ) ; } } flow . viewStack . splice ( index , 1 ) ; } ( view , flow ) ) ; OS_ANDROID && flow . children . splice ( index , 1 ) ; window . close ( ) ; }
@method _closeWindow
 @private
@method _closeWindow @private
// Really weird if happens. /* Closing the last window, the one displayed in the drawer */ // There is at least 2 views // There are previous windows //Otherwise, back to the root