How can I restrict the dropdown to visible space?

When I use the standard select dropdown, it will size the dropdown to the available visible space in the browser window and add a scrollbar in the dropdown.
When I use the Select2 dropdown, it will size the dropdown to the configured size regardless of the available visible space in the browser window.
How can I change the Select2 dropdown to act as the standard select dropdown and adapt the dropdown size to the visible space?