Added support for closing files on middle click

Implemented as requested in #3889