You handled this perfectly. Here’s the simple step-by-step:
1. Don’t panic. They cannot hurt you. Even
if one lands on you, it will just crawl or try to fly away.
2. Turn off the bathroom light and close the door. Darkness will calm it down, and it will stop banging into surfaces.
3. Open an outside window (if possible) and turn on an outside light. It will fly toward that light and leave on its own. This is the kindest method.
4. Alternatively, capture it gently. Use a cup and a piece of stiff paper or cardboard. Slide the paper under the cup, carry it outside,