Sonoff SV relay does not turn off sometimes

I am using a Sonoff SV and ESP home to control my garage door. It has worked flawlessly for 3 years with the exception of about once per week or so, the relay does not turn off. To trigger my garage door, I turn on the relay and then pause for 1/2 second and then turn it off. Sometimes the relay just stays open which requires me to have to hit the button again to turn it off. Not a but deal, but it messes with my automation, and also does not allow me to use the real button on the wall in the garage as their is not power, the LED is not lit. Should I adjust the 1/2 second pause? Has anyone else had these issues?

Here is my code for the switch.

esphome:
name: mygarage
platform: ESP8266
board: esp01_1m

wifi:
  ssid: 
  password: "
  manual_ip:
    static_ip: 192.168.1.146
    gateway: 192.168.1.1
    subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API bw
api:
ota:
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      #inverted: True
    name: "Welle Garage Door"
    device_class: garage_door
  - platform: gpio
    pin: 
      number: GPIO12
      allow_other_uses: true
    name: "Garage Relay Button"
    filters:
      - delayed_off: 20seconds
    
sensor:
  - platform: wifi_signal
    name: "Garage WiFi Signal"
    update_interval: 60s
    
switch:
  - platform: gpio
    pin: 
      number: GPIO12
      allow_other_uses: true
    id: relay
  - platform: template
    icon: "mdi:arrow-up-down-bold-outline"
    name: "Welle Garage Switch"
    turn_on_action:
    - switch.turn_on: relay
    - delay: 500ms
    - switch.turn_off: relay