For Bootstrap 3.x this worked great with no change to their example code:
$(window).bind('resize load', function() {
if ($(this).width() < 767) {
$('.collapse').removeClass('in');
$('.collapse').addClass('out');
} else {
$('.collapse').removeClass('out');
$('.collapse').addClass('in');
}
});