Small tweak. Still works well

Added an elif statement so the program works if it detects a spike that
starts but doesn't end before time runs out.