Fixed closing tab behavior (fixed #938)

TBR: @devoncarew
cc @ussuri