Made option "closeOnSelect" work.

Hey -

I noticed "closeOnSelect" option in documentation but it was not working.
So I've added logic to make it work.

Please let me know if you have any questions.