Senate reaches deal to end shutdown, avoid default