This is actually correct. If you just power off the STA, then the AP does not immediately notice the STA is gone. No packet (like a WiFi deauthentication packet) is sent from the STA to the AP, with a power loss the STA just stops sending from the AP’s point of view. The STA is only registered as “disconencted” when a timeout occurs and no data is received from the STA.
Per ESP-IDF documentation, that timeout is 300 seconds (=5 minutes). So that’s where your “a few minutes later” is coming from.
If you don’t like this behavior and would want your AP to behave more aggressively, change it in the firmware running the SoftAP.
#include "esp_wifi.h" /* may be needed if not auto-included by just WiFi.h */
/* 15 seconds timeout for a non-sending STA to be seen as 'disconnected' on the SoftAP interface */
esp_wifi_set_inactive_time(WIFI_IF_AP, 15);
Conversely, a STA will not immediately notice a powered-down AP, again per above that timeout is just 6 seconds though. You can change it with esp_wifi_set_inactive_time(WIFI_IF_STA, 3); to e.g. 3 seconds.
