You've probably gotten annoyed at a railroad crossing gate that takes a bit to reopen after a train passes, but there's a good reason for it.